Package: writerai
Python SDKAI for everyone.SDK InstallationpipinstallwriteraiAuthenticationWriter authenticates your API requests using your account’s API keys. If you do not include your key when making an API request, or use one that is incorrect or outdated, Writer returns an error.Your API keys are available in the account dashboard. We include randomly generated API keys in our code examples if you are not logged in. Replace these with your own or log in to see code examples populated with your own API keys.If you cannot see your secret API keys in the Dashboard, this means you do not have access to them. Contact your Writer account owner and ask to be added to their team as a developer.SDK Example UsageExampleimportwriters=writer.Writer(api_key="<YOUR_API_KEY_HERE>",organization_id=850421,)res=s.billing.get_subscription_details()ifres.subscription_public_response_apiisnotNone:# handle responsepassAvailable Resources and Operationsbillingget_subscription_details- Get your organization subscription detailsai_content_detectordetect- Content detector apicontentcheck- Check your content against your preset styleguide.correct- Apply the style guide suggestions directly to your content.co_writegenerate_content- Generate content using predefined templateslist_templates- Get a list of your existing CoWrite templatesfilesdelete- Delete fileget- Get filelist- List filesupload- Upload filemodelslist- List available LLM modelscompletionscreate- Create completion for LLM modelcreate_model_customization_completion- Create completion for LLM customization modelmodel_customizationcreate- Create model customizationdelete- Delete Model customizationget- Get model customizationlist- List model customizationsdownload_the_customized_modelfetch_file- Download your fine-tuned model (available only for Palmyra Base and Palmyra Large)documentget- Get document detailslist- List team documentssnippetdelete- Delete snippetsfind- Find snippetsupdate- Update snippetsstyleguideget- Page detailslist_pages- List your styleguide pagesterminologyadd- Add termsdelete- Delete termsfind- Find termsupdate- Update termsuserlist- List usersGlobal ParametersA parameter is configured globally. This parameter must be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.For example, you can setorganizationIdto99895at SDK initialization and then you do not have to pass the same value on calls to operations likedetect. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.Available GlobalsThe following global parameter is available. The required parameter must be set when you initialize the SDK client.NameTypeRequiredDescriptionorganization_idint✔️The organization_id parameter.Exampleimportwriters=writer.Writer(api_key="<YOUR_API_KEY_HERE>",organization_id=496531,)res=s.ai_content_detector.detect(content_detector_request=writer.ContentDetectorRequest(input='string',),organization_id=592237)ifres.classesisnotNone:# handle responsepassError HandlingHandling errors in this SDK should largely match your expectations.  All operations return a response object or raise an error.  If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type.Error ObjectStatus CodeContent Typemodels.FailResponse400,401,403,404,500application/jsonmodels.SDKError4x-5xx/Exampleimportwriters=writer.Writer(api_key="<YOUR_API_KEY_HERE>",organization_id=850421,)res=Nonetry:res=s.billing.get_subscription_details()exceptmodels.FailResponsease:print(e)# handle exceptionraise(e)exceptmodels.SDKErrorase:print(e)# handle exceptionraise(e)ifres.subscription_public_response_apiisnotNone:# handle responsepassServer SelectionSelect Server by IndexYou can override the default server globally by passing a server index to theserver_idx: intoptional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:#ServerVariables0https://enterprise-api.writer.comNoneExampleimportwriters=writer.Writer(server_idx=0,api_key="<YOUR_API_KEY_HERE>",organization_id=850421,)res=s.billing.get_subscription_details()ifres.subscription_public_response_apiisnotNone:# handle responsepassOverride Server URL Per-ClientThe default server can also be overridden globally by passing a URL to theserver_url: stroptional parameter when initializing the SDK client instance. For example:importwriters=writer.Writer(server_url="https://enterprise-api.writer.com",api_key="<YOUR_API_KEY_HERE>",organization_id=850421,)res=s.billing.get_subscription_details()ifres.subscription_public_response_apiisnotNone:# handle responsepassCustom HTTP ClientThe Python SDK makes API calls using therequestsHTTP library.  In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a customrequests.Sessionobject.For example, you could specify a header for every request that this sdk makes as follows:importwriterimportrequestshttp_client=requests.Session()http_client.headers.update({'x-custom-header':'someValue'})s=writer.Writer(client:http_client)AuthenticationPer-Client Security SchemesThis SDK supports the following security scheme globally:NameTypeSchemeapi_keyapiKeyAPI keyTo authenticate with the API theapi_keyparameter must be set when initializing the SDK client instance. For example:importwriters=writer.Writer(api_key="<YOUR_API_KEY_HERE>",organization_id=850421,)res=s.billing.get_subscription_details()ifres.subscription_public_response_apiisnotNone:# handle responsepassSDK Generated bySpeakeasy