Skip to main content
Together AI implements the OpenAI Responses API at POST /v1/responses. If your app is built on the Responses API, change the API key, base URL, and model to run it on open-source models hosted by Together. Together doesn’t support stored responses, so send the full conversation with each request.

Set up the client

Install the OpenAI SDK for your language:
Set api_key to your Together API key and base_url to https://api.together.ai/v1, then create a response:
When the model reasons, the response’s output array starts with a reasoning item, followed by a message item with the answer. The SDKs’ output_text helper returns the answer text. With cURL, read it from the message item’s content[0].text. input accepts a string or a list of items. For a system prompt, pass instructions or include a system or developer message in the input list.

Supported models

Supported models differ between serverless inference and dedicated model inference: Other serverless models can accept Responses API requests, but they aren’t supported and may return malformed output. To send requests to dedicated model inference, set the base URL to https://api-inference.together.ai/v1 and pass your endpoint string as model. To use the Responses API with an existing dedicated endpoint or a model that isn’t supported yet, contact sales.

Endpoint support

Stream responses

Set stream to true to receive server-sent events as the model generates them:
The stream starts with response.created and response.in_progress, and ends with response.completed. In between, each output item arrives as response.output_item.added, then its deltas, then response.output_item.done. The delta events depend on the item type:
  • Reasoning: response.reasoning_text.delta and response.reasoning_text.done.
  • Answer text: response.content_part.added, response.output_text.delta, response.output_text.done, and response.content_part.done.
  • Function calls: response.function_call_arguments.delta and response.function_call_arguments.done.

Build multi-turn conversations

Together doesn’t support stored responses, so previous_response_id and the Conversations API aren’t available. To continue a conversation, append the previous response’s output items to your input, add the next user message, and send the full list:

Call functions

Define each function with type: "function", a name, a description, and JSON Schema parameters. When the model calls a function, the response has a function_call item with the function name, a JSON-encoded arguments string, and a call_id. To return the results, append the response’s output items to your input, add a function_call_output item with the matching call_id for each call, and send the full list back:
tool_choice accepts auto, required, none, and a named function ({"type": "function", "name": "get_weather"}). Set parallel_tool_calls to false to get at most one call per turn. Together doesn’t run tools itself, so your app runs every tool the model calls. Use function tools, custom tools, or the shell, local_shell, and apply_patch tools. Hosted tools (such as file_search, code_interpreter, image_generation, and computer_use_preview) and remote MCP servers return a 400. Together removes a web_search tool from the request, but forcing one with tool_choice returns a 400.

Control reasoning

Set reasoning.effort to none, minimal, low, medium, high, or xhigh:
Reasoning on Together differs from OpenAI’s API:
  • Effort levels: Together passes the level to the model’s chat template, so its effect depends on the model. GLM-5.3 reasons at every level, including none. On GLM-5.2, minimal turns reasoning off, low and medium request maximum effort, and high requests high effort.
  • Reasoning text: Each reasoning item carries the full reasoning text in content, as reasoning_text parts.
  • reasoning.summary: Together doesn’t generate summaries, so summary is always empty.
  • encrypted_content: If you request include: ["reasoning.encrypted_content"], encrypted_content holds a base64-encoded copy of the reasoning text. It isn’t encrypted.

Get structured outputs

To constrain the answer to a JSON schema, pass the schema in text.format:

Token usage and billing

The response’s usage object reports input_tokens, output_tokens, and total_tokens. input_tokens_details.cached_tokens counts the prompt tokens served from Together’s automatic prefix cache. output_tokens_details.reasoning_tokens counts reasoning tokens, which are included in output_tokens. Together bills Responses API requests the same way as chat completions: per token at each model’s serverless prices, or per GPU-minute on dedicated model inference.

Other differences from OpenAI’s API

  • store: Together doesn’t store responses, so the response reports store: false even when you set it to true.
  • previous_response_id and conversation: Both return a 400. Send the full history instead.
  • background: Setting it to true returns a 400.
  • Images and files: GLM-5.3 and GLM-5.2 don’t accept images, so an input_image part returns a 400. The exception is an input_image part that references only a file_id, which Together drops without an error. An input_file part also returns a 400.

Errors

Errors use the same JSON format as OpenAI’s API, and the OpenAI SDKs raise their usual exception class for each HTTP status code. For example, responses.retrieve returns a 404 with this body:
Together’s type and code values don’t always match OpenAI’s, so branch on the HTTP status code, not on type or code. For the causes and fixes of each status code, see Error codes.

Next steps

Messages API

Call Together models with the Anthropic Messages API.

Together Link

Run Codex and other coding agents on Together models.