Skip to main content
The full OpenAPI spec is available at openapi.yaml.
Together’s API is compatible with the OpenAI REST API and SDKs across chat, completions, vision, image generation, text-to-speech, and embeddings. If you have an application that uses the OpenAI Python or TypeScript client (or cURL against api.openai.com), you can point it at models hosted on Together with two changes: the API key and base URL. This page is a configuration reference for the Together AI OpenAI compatibility layer. For end-to-end examples of each capability, follow the links to the dedicated capability pages.

Drop-in client setup

To point an OpenAI client at Together, set api_key to your Together API key and base_url to https://api.together.ai/v1. The examples read the key from the TOGETHER_API_KEY environment variable:
Find your API key on your project’s API keys page in the Together AI console. If you don’t have an account, register for free. Set model to any Together model ID. Together model IDs follow the <provider>/<model_name> convention rather than OpenAI’s flat namespace.

Geo-specific inference

To keep inference processing in the United States, set the base URL to https://us-api.together.ai/v1. The US endpoint supports select models and charges 1.25× standard serverless rates for input, cached input, and output tokens. See geo-specific inference for supported models and pricing.

Endpoint compatibility matrix

The following OpenAI SDK methods route to Together-native endpoints when the base URL is set to https://api.together.ai/v1. Together-native endpoints not exposed by the OpenAI SDKs (call them with requests, fetch, or the Together SDK):

Drop-in compatibility

These capabilities work without code changes beyond the API key and base URL. Each row maps a Together capability to the OpenAI SDK method that drives it. Video generation is Together-native and isn’t exposed through the OpenAI SDK.

Known incompatibilities

Model identifiers

Together model IDs are namespaced (openai/gpt-oss-120b, meta-models/Muse-Glimmer-30B, black-forest-labs/FLUX.2-dev). OpenAI model strings like gpt-4o or text-embedding-3-large return a 404. Browse the full list at Available models.

Endpoints not implemented

  • Assistants, Threads, and Runs are not implemented. Build the agent loop yourself with function calling.
  • The OpenAI-shaped Batch API and Files API are not exposed through /v1. Together has its own batch API and files API.
  • moderations.create is not implemented and returns a 404. No moderation models are available, so prompt a chat model to classify content instead.

Parameter quirks

  • logprobs returns Together’s own shape, which is richer than OpenAI’s.
  • seed is best-effort. Determinism is not guaranteed across replicas, model versions, or load conditions.
  • n (multiple completions per request) is supported on most chat models but not on every model. Loop client-side if a model rejects it.
  • logit_bias is not supported on most models.
  • service_tier, store, metadata, and prediction are accepted but ignored.
  • reasoning_effort works on GPT-OSS models ("low", "medium", "high"). Other reasoning controls (Together’s reasoning={"enabled": ...} toggle, chat_template_kwargs) are not part of OpenAI’s API surface.
  • Vision models accept image_url with both remote URLs and base64 data URIs. The detail field is accepted but ignored.

Response shape differences

  • usage always includes prompt_tokens, completion_tokens, and total_tokens. Extra token counts vary in location by model, so read both shapes defensively:
    • Reasoning models (for example zai-org/GLM-5.2, deepseek-ai/DeepSeek-V4-Pro-0813, Qwen/Qwen3.6-Plus) nest them OpenAI-style: cached prompt tokens under usage.prompt_tokens_details.cached_tokens and reasoning tokens under usage.completion_tokens_details.reasoning_tokens.
    • Some non-reasoning models return cached_tokens flat at the top level of usage, with no *_details objects.
    A client configured for only one shape will return 0 for all others (with no error message). Fall back across both locations, for example (usage.prompt_tokens_details or {}).get("cached_tokens") or usage.get("cached_tokens", 0).
  • Reasoning models return the chain of thought in a reasoning or reasoning_content field on the assistant message (not OpenAI’s nested reasoning object). The field name depends on the model. Pass it back under the same key when you send a prior turn to the API for preserved thinking or multi-turn tool calling.
  • id and system_fingerprint are present but use Together’s formats. Don’t parse them as OpenAI IDs.
  • images.generate returns url or b64_json per the response_format param, matching OpenAI. Some image models also return Together-specific metadata fields (for example seed).

Errors

Together returns OpenAI-shaped error objects ({ "error": { "message", "type", "code" } }), but type and code values are Together’s. Match on HTTP status (400, 401, 404, 429, 500, 503) for portable handling.

Community libraries

Most community-built OpenAI libraries also work with the Together API. If you see unexpected behavior, contact support.