Every API here is available over the APIs.io API and to AI agents over MCP.
openapi: 3.2.0
info:
title: File Generation API
version: '1.0'
servers:
- url: https://api.writer.com
security:
- bearerAuth: []
tags:
- name: Generation API
paths:
/v1/chat:
post:
security:
- bearerAuth: []
tags:
- Generation API
summary: Chat completion
description: Generate a chat completion based on the provided messages. The response shown below is for non-streaming. To learn about streaming responses, see the [chat completion guide](https://dev.writer.com/home/chat-completion).
operationId: chat
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/chat_request'
required: true
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/chat_response'
example:
id: 57e4f58f-f7b1-41d8-be17-a6279c073aad
object: chat.completion
choices:
- index: 0
finish_reason: stop
message:
content: The earnings report shows...
role: assistant
refusal: null
tool_calls: []
graph_data:
sources: []
status: finished
subqueries: []
llm_data:
prompt: Write a memo summarizing this earnings report.
model: palmyra-x5
translation_data: null
web_search_data: null
created: 1715361795
model: palmyra-x5
usage:
prompt_tokens: 40
total_tokens: 340
completion_tokens: 300
prompt_token_details:
cached_tokens: 0
completion_token_details:
reasoning_tokens: 0
system_fingerprint: v1
service_tier: standard
text/event-stream:
schema:
type: array
items:
$ref: '#/components/schemas/chat_completion_chunk'
examples:
'200':
value:
id: 57e4f58f-f7b1-41d8-be17-a6279c073aad
object: chat.completion
choices:
- index: 0
finish_reason: length
message:
content: The earnings report shows...
role: assistant
tool_calls: []
refusal: null
graph_data:
sources: []
status: finished
subqueries: []
llm_data:
prompt: Write a memo summarizing this earnings report.
model: palmyra-x5
translation_data: null
web_search_data: null
delta:
content: The earnings report shows...
role: assistant
tool_calls: []
refusal: null
graph_data:
sources: []
status: finished
subqueries: []
llm_data:
prompt: Write a memo summarizing this earnings report.
model: palmyra-x5
translation_data: null
web_search_data: null
created: 1715361795
model: palmyra-x5
usage:
prompt_tokens: 40
total_tokens: 340
completion_tokens: 300
prompt_token_details:
cached_tokens: 0
completion_token_details:
reasoning_tokens: 0
system_fingerprint: v1
service_tier: standard
x-codeSamples:
- lang: cURL
source: "curl --location --request POST https://api.writer.com/v1/chat \\\n --header \"Authorization: Bearer <token>\" \\\n --header \"Content-Type: application/json\" \\\n--data-raw '{\"model\":\"palmyra-x5\",\"messages\":[{\"content\":\"Write a memo summarizing this earnings report.\",\"role\":\"user\"}]}'"
- lang: JavaScript
source: "import Writer from 'writer-sdk';\n\nconst client = new Writer({\n apiKey: process.env['WRITER_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const chat = await client.chat.chat({\n messages: [{ content: 'Write a memo summarizing this earnings report.', role: 'user' }],\n model: 'palmyra-x5',\n });\n\n console.log(chat.id);\n}\n\nmain();"
- lang: Python
source: "import os\nfrom writerai import Writer\n\nclient = Writer(\n # This is the default and can be omitted\n api_key=os.environ.get(\"WRITER_API_KEY\"),\n)\nchat = client.chat.chat(\n messages=[{\n \"content\": \"Write a memo summarizing this earnings report.\",\n \"role\": \"user\",\n }],\n model=\"palmyra-x5\",\n)\nprint(chat.id)"
/v1/completions:
post:
security:
- bearerAuth: []
tags:
- Generation API
summary: Text generation
description: Generate text completions using the specified model and prompt. This endpoint is useful for text generation tasks that don't require conversational context.
operationId: completions
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/completions_request'
required: true
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/completions_response'
text/event-stream:
schema:
type: array
items:
$ref: '#/components/schemas/streaming_data'
x-codeSamples:
- lang: cURL
source: "curl --location --request POST https://api.writer.com/v1/completions \\\n --header \"Authorization: Bearer <token>\" \\\n --header \"Content-Type: application/json\" \\\n--data-raw '{\"model\":\"palmyra-x-003-instruct\",\"prompt\":\"Write me a short SEO article about camping gear\",\"max_tokens\":150,\"temperature\":0.7,\"top_p\":0.9,\"stop\":[\".\"],\"best_of\":1,\"random_seed\":42,\"stream\":false}'"
- lang: JavaScript
source: "import Writer from 'writer-sdk';\n\nconst client = new Writer({\n apiKey: process.env['WRITER_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const completion = await client.completions.create({\n model: 'palmyra-x-003-instruct',\n prompt: 'Write me a short SEO article about camping gear',\n });\n\n console.log(completion.choices);\n}\n\nmain();"
- lang: Python
source: "import os\nfrom writerai import Writer\n\nclient = Writer(\n # This is the default and can be omitted\n api_key=os.environ.get(\"WRITER_API_KEY\"),\n)\ncompletion = client.completions.create(\n model=\"palmyra-x-003-instruct\",\n prompt=\"Write me a short SEO article about camping gear\",\n)\nprint(completion.choices)"
/v1/models:
get:
security:
- bearerAuth: []
tags:
- Generation API
summary: List models
description: Retrieve a list of available models that can be used for text generation, chat completions, and other AI tasks.
operationId: models
x-mint:
mcp:
enabled: true
name: list-models
description: Get a list of available Writer AI models
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/models_response'
x-codeSamples:
- lang: cURL
source: "curl --location --request GET https://api.writer.com/v1/models \\\n --header \"Authorization: Bearer <token>\""
- lang: JavaScript
source: "import Writer from 'writer-sdk';\n\nconst client = new Writer({\n apiKey: process.env['WRITER_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const model = await client.models.list();\n\n console.log(model.models);\n}\n\nmain();"
- lang: Python
source: "import os\nfrom writerai import Writer\n\nclient = Writer(\n # This is the default and can be omitted\n api_key=os.environ.get(\"WRITER_API_KEY\"),\n)\nmodel = client.models.list()\nprint(model.models)"
/v1/applications:
get:
security:
- bearerAuth: []
tags:
- Generation API
summary: List applications
description: Retrieves a paginated list of no-code agents (formerly called no-code applications) with optional filtering and sorting capabilities.
parameters:
- name: order
in: query
required: false
description: Sort order for the results based on creation time.
schema:
type: string
default: desc
enum:
- asc
- desc
- name: before
in: query
required: false
description: Return results before this application ID for pagination.
schema:
type: string
format: uuid
- name: after
in: query
required: false
description: Return results after this application ID for pagination.
schema:
type: string
format: uuid
- name: limit
in: query
required: false
description: Maximum number of applications to return in the response.
schema:
type: integer
format: int32
default: 50
- name: type
in: query
required: false
description: Filter applications by their type.
schema:
$ref: '#/components/schemas/application_type'
default: generation
responses:
'200':
description: Successfully retrieved list of applications.
content:
application/json:
schema:
$ref: '#/components/schemas/get_applications_response'
x-codeSamples:
- lang: cURL
source: "curl --location --request GET https://api.writer.com/v1/applications \\\n --header \"Authorization: Bearer <token>\""
- lang: JavaScript
source: "import Writer from 'writer-sdk';\n\nconst client = new Writer({\n apiKey: process.env['WRITER_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n // Automatically fetches more pages as needed.\n for await (const applicationListResponse of client.applications.list()) {\n console.log(applicationListResponse.id);\n }\n}\n\nmain();"
- lang: Python
source: "import os\nfrom writerai import Writer\n\nclient = Writer(\n api_key=os.environ.get(\"WRITER_API_KEY\"), # This is the default and can be omitted\n)\npage = client.applications.list()\npage = page.data[0]\nprint(page.id)"
/v1/applications/{application_id}:
get:
security:
- bearerAuth: []
tags:
- Generation API
summary: Application details
description: Retrieves detailed information for a specific no-code agent (formerly called no-code applications), including its configuration and current status.
parameters:
- name: application_id
in: path
required: true
description: Unique identifier of the application to retrieve.
schema:
type: string
responses:
'200':
description: Successfully retrieved application details.
content:
application/json:
schema:
$ref: '#/components/schemas/application_with_inputs'
x-codeSamples:
- lang: cURL
source: "curl --location --request GET https://api.writer.com/v1/applications/{application_id} \\\n --header \"Authorization: Bearer <token>\""
- lang: JavaScript
source: "import Writer from 'writer-sdk';\n\nconst client = new Writer({\n apiKey: process.env['WRITER_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const application = await client.applications.retrieve('application_id');\n\n console.log(application.id);\n}\n\nmain();"
- lang: Python
source: "import os\nfrom writerai import Writer\n\nclient = Writer(\n api_key=os.environ.get(\"WRITER_API_KEY\"), # This is the default and can be omitted\n)\napplication = client.applications.retrieve(\n \"application_id\",\n)\nprint(application.id)"
post:
security:
- bearerAuth: []
tags:
- Generation API
summary: Generate from application
description: Generate content from an existing no-code agent (formerly called no-code applications) with inputs.
operationId: generateContent
parameters:
- name: application_id
in: path
required: true
schema:
type: string
format: uuid
description: The unique identifier of a [no-code agent](/no-code/introduction) in AI Studio.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/generate_application_request'
required: true
responses:
'200':
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/generate_application_response'
example:
title: Alt text
suggestion: A modern dining room with a minimalist design.
text/event-stream:
schema:
type: array
items:
$ref: '#/components/schemas/generate_application_response_chunk'
x-codeSamples:
- lang: cURL
source: "curl --location --request POST https://api.writer.com/v1/applications/{application_id} \\\n --header \"Authorization: Bearer <token>\" \\\n --header \"Content-Type: application/json\" \\\n--data-raw '{\"inputs\":[{\"id\": \"Image ID\", \"value\": [\"12345\"]}]}'"
- lang: JavaScript
source: "import Writer from 'writer-sdk';\n\nconst client = new Writer({\n apiKey: process.env['WRITER_API_KEY'], // This is the default and can be omitted\n});\n\nasync function main() {\n const response = await client.applications.generateContent('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {\n inputs: [\n { id: 'id', value: ['string', 'string', 'string'] },\n { id: 'id', value: ['string', 'string', 'string'] },\n { id: 'id', value: ['string', 'string', 'string'] },\n ],\n });\n\n console.log(response.suggestion);\n}\n\nmain();"
- lang: Python
source: "import os\nfrom writerai import Writer\n\nclient = Writer(\n # This is the default and can be omitted\n api_key=os.environ.get(\"WRITER_API_KEY\"),\n)\nresponse = client.applications.generate_content(\n application_id=\"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e\",\n inputs=[{\n \"id\": \"id\",\n \"value\": [\"string\", \"string\", \"string\"],\n }, {\n \"id\": \"id\",\n \"value\": [\"string\", \"string\", \"string\"],\n }, {\n \"id\": \"id\",\n \"value\": [\"string\", \"string\", \"string\"],\n }],\n)\nprint(response.suggestion)"
components:
schemas:
llm_tool:
title: LLM tool
required:
- function
- type
type: object
properties:
type:
type: string
description: The type of tool.
enum:
- llm
function:
$ref: '#/components/schemas/llm_function'
application_status:
title: application_status
description: 'Current deployment status of the application. Note: currently only `deployed` applications are returned.'
type: string
enum:
- deployed
- draft
completion_token_details:
title: completion_token_details
required:
- reasoning_tokens
type: object
properties:
reasoning_tokens:
type: integer
format: int32
translation_function:
title: Translation function
description: A tool that uses Palmyra Translate to translate text.
required:
- model
- formality
- length_control
- mask_profanity
type: object
properties:
model:
type: string
description: The model to use for translation.
enum:
- palmyra-translate
source_language_code:
type: string
description: Optional. The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) language code of the original text to translate. For example, `en` for English, `zh` for Chinese, `fr` for French, `es` for Spanish. If the language has a variant, the code appends the two-digit [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). If you do not provide a language code, the LLM detects the language of the text.
target_language_code:
type: string
description: Optional. The [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) language code of the target language for the translation. For example, `en` for English, `zh` for Chinese, `fr` for French, `es` for Spanish. If the language has a variant, the code appends the two-digit [ISO-3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). If you do not provide a language code, the LLM uses the content of the chat message to determine the target language.
formality:
type: boolean
description: Whether to use formal or informal language in the translation. See the [list of languages that support formality](https://dev.writer.com/api-reference/translation-api/language-support#formality). If the language does not support formality, this parameter is ignored.
length_control:
type: boolean
description: Whether to control the length of the translated text. See the [list of languages that support length control](https://dev.writer.com/api-reference/translation-api/language-support#length-control). If the language does not support length control, this parameter is ignored.
mask_profanity:
type: boolean
description: Whether to mask profane words in the translated text. See the [list of languages that do not support profanity masking](https://dev.writer.com/api-reference/translation-api/language-support#profanity-masking). If the language does not support profanity masking, this parameter is ignored.
source:
title: source
description: A source snippet containing text and fileId from Knowledge Graph content.
required:
- file_id
- snippet
type:
- object
- 'null'
properties:
file_id:
type: string
description: The unique identifier of the file in your Writer account.
snippet:
type: string
description: The exact text snippet from the source document that was used to support the response.
logprobs_token:
title: logprobs_token
required:
- token
- logprob
- top_logprobs
type: object
properties:
token:
type: string
logprob:
type: number
format: double
bytes:
type: array
items:
type: integer
format: int32
top_logprobs:
type: array
items:
$ref: '#/components/schemas/top_log_prob'
application_input_text_options:
title: Text
description: Configuration options specific to text input fields.
required:
- max_fields
- min_fields
type: object
properties:
max_fields:
type: integer
format: int32
description: Maximum number of text fields allowed.
min_fields:
type: integer
format: int32
description: Minimum number of text fields required.
chat_request:
required:
- model
- messages
type: object
properties:
model:
type: string
description: The [ID of the model](https://dev.writer.com/home/models) to use for creating the chat completion. Supports `palmyra-x5`, `palmyra-x4`, `palmyra-fin`, `palmyra-med`, `palmyra-creative`, and `palmyra-x-003-instruct`.
messages:
type: array
items:
$ref: '#/components/schemas/chat_message'
minItems: 1
description: An array of message objects that form the conversation history or context for the model to respond to. The array must contain at least one message.
max_tokens:
type: integer
format: int32
description: Defines the maximum number of tokens (words and characters) that the model can generate in the response. This can be adjusted to allow for longer or shorter responses as needed. The maximum value varies by model. See the [models overview](/home/models) for more information about the maximum number of tokens for each model.
temperature:
type: number
format: double
default: 1
description: Controls the randomness or creativity of the model's responses. A higher temperature results in more varied and less predictable text, while a lower temperature produces more deterministic and conservative outputs.
top_p:
type: number
format: double
description: Sets the threshold for "nucleus sampling," a technique to focus the model's token generation on the most likely subset of tokens. Only tokens with cumulative probability above this threshold are considered, controlling the trade-off between creativity and coherence.
n:
type: integer
format: int32
description: Specifies the number of completions (responses) to generate from the model in a single request. This parameter allows for generating multiple responses, offering a variety of potential replies from which to choose.
stop:
oneOf:
- type: array
items:
type: string
- type: string
description: A token or sequence of tokens that, when generated, will cause the model to stop producing further content. This can be a single token or an array of tokens, acting as a signal to end the output.
logprobs:
type: boolean
default: 'false'
description: Specifies whether to return log probabilities of the output tokens.
stream:
type: boolean
description: Indicates whether the response should be streamed incrementally as it is generated or only returned once fully complete. Streaming can be useful for providing real-time feedback in interactive applications.
default: false
tools:
type: array
description: An array containing tool definitions for tools that the model can use to generate responses. The tool definitions use JSON schema. You can define your own functions or use one of the built-in `graph`, `llm`, `translation`, or `vision` tools. Note that you can only use one built-in tool type in the array (only one of `graph`, `llm`, `translation`, or `vision`). You can pass multiple [custom tools](https://dev.writer.com/home/tool-calling) of type `function` in the same request.
items:
$ref: '#/components/schemas/tool'
minItems: 1
tool_choice:
$ref: '#/components/schemas/tool_choice'
stream_options:
$ref: '#/components/schemas/stream_options'
response_format:
$ref: '#/components/schemas/response_format'
example:
model: palmyra-x5
messages:
- content: Write a memo summarizing this earnings report.
role: user
models_response:
required:
- models
type: object
properties:
models:
type: array
description: The [ID of the model](https://dev.writer.com/home/models) to use for processing the request.
items:
$ref: '#/components/schemas/model_info'
example:
models:
- name: Palmyra X 003 Instruct
id: palmyra-x-003-instruct
- name: Palmyra Med
id: palmyra-med
- name: Palmyra Financial
id: palmyra-fin
- name: Palmyra X4
id: palmyra-x4
- name: Palmyra X5
id: palmyra-x5
- name: Palmyra Creative
id: palmyra-creative
vision_tool:
title: Vision tool
required:
- function
- type
type: object
properties:
type:
type: string
description: The type of tool.
enum:
- vision
function:
$ref: '#/components/schemas/vision_function'
application_input_media_options:
title: Media
description: Configuration options specific to media upload input fields.
required:
- file_types
- max_image_size_mb
type: object
properties:
file_types:
type: array
description: List of allowed media file types.
items:
type: string
max_image_size_mb:
type: integer
format: int32
description: Maximum media file size allowed in megabytes.
generate_application_input:
title: generate_application_input
required:
- id
- value
type: object
properties:
id:
type: string
description: The unique identifier for the input field from the application. All input types from the No-code application are supported (i.e. Text input, Dropdown, File upload, Image input). The identifier should be the name of the input type.
value:
type: array
items:
type: string
description: "The value for the input field. \n\nIf the input type is \"File upload\", you must pass the `file_id` of an uploaded file. You cannot pass a file object directly. See the [file upload endpoint](https://dev.writer.com/api-reference/file-api/upload-files) for instructions on uploading files or the [list files endpoint](https://dev.writer.com/api-reference/file-api/get-all-files) for how to see a list of uploaded files and their IDs."
chat_response:
required:
- id
- object
- choices
- created
- model
type: object
properties:
id:
type: string
format: uuid
description: A globally unique identifier (UUID) for the response generated by the API. This ID can be used to reference the specific operation or transaction within the system for tracking or debugging purposes.
object:
type: string
description: The type of object returned, which is always `chat.completion` for chat responses.
enum:
- chat.completion
choices:
type: array
items:
$ref: '#/components/schemas/chat_completion_choice'
minItems: 1
description: An array of objects representing the different outcomes or results produced by the model based on the input provided.
created:
type: integer
format: int64
description: The Unix timestamp (in seconds) when the response was created. This timestamp can be used to verify the timing of the response relative to other events or operations.
model:
type: string
description: Identifies the specific model used to generate the response.
usage:
$ref: '#/components/schemas/chat_completion_usage'
system_fingerprint:
type: string
description: A string representing the backend configuration that the model runs with.
service_tier:
type: string
description: The service tier used for processing the request.
example:
id: 3c90c3cc-0d44-4b50-8888-8dd25736052a
choices:
- finish_reason: stop
message:
content: Hello! How can I assist you today?
role: user
created: 1678587532773
model: palmyra-x5
llm_function:
title: LLM function
description: A tool that uses another Writer model to generate a response.
required:
- description
- model
type: object
properties:
description:
type: string
description: A description of the model to use.
model:
type: string
description: The model to use.
tool_call_streaming:
title: tool_call
type: object
required:
- index
properties:
index:
type: integer
format: int32
id:
type: string
type:
type: string
enum:
- function
function:
$ref: '#/components/schemas/function'
application_input_type:
title: application_input_type
description: Type of input field determining its behavior and validation rules.
type: string
enum:
- text
- dropdown
- file
- media
translation_tool:
title: Translation tool
description: A tool that uses Palmyra Translate to translate text. Note that this tool does not stream results. The response is returned after the translation is complete.
required:
- function
- type
type: object
properties:
type:
type: string
description: The type of tool.
enum:
- translation
function:
$ref: '#/components/schemas/translation_function'
response_format:
title: response_format
description: 'The response format to use for the chat completion, available with `palmyra-x4` and `palmyra-x5`.
`text` is the default response format. [JSON Schema](https://json-schema.org/) is supported for structured responses. If you specify `json_schema`, you must also provide a `json_schema` object.'
required:
- type
type: object
properties:
type:
type: string
description: The type of response format to use.
enum:
- text
- json_schema
json_schema:
type: object
description: The JSON schema to use for the response format.
completions_choice:
required:
- text
type: object
properties:
text:
type: string
description: The generated text output from the model, which forms the main content of the response.
log_probs:
$ref: '#/components/schemas/logprobs'
composite_content:
title: composite_content
description: 'A union type that can contain either text or image content fragments. This enables chat messages to include mixed content types, allowing users to send both text and images in a single message. Note: Image fragments are only supported with the Palmyra X5 model.'
oneOf:
- $ref: '#/components/schemas/text_fragment'
- $ref: '#/components/schemas/image_fragment'
chat_message_role:
type: string
enum:
- user
- assistant
- system
references:
title: references
description: Detailed source information organized by reference type, providing comprehensive metadata about the sources used to generate the response.
type: object
properties:
files:
type: array
description: Array of file-based references from uploaded documents in the Knowledge Graph.
items:
$ref: '#/components/schemas/file'
minItems: 1
web:
type: array
description: Array of web-based references from online sources accessed during the query.
items:
$ref: '#/components/schemas/web'
minItems: 1
top_
# --- truncated at 32 KB (68 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/writer/refs/heads/main/openapi/writer-generation-api-api-openapi.yml