# Together AI

[Together AI](https://docs.together.ai/) provides hosted inference for open and partner models. Applications call selected models through stable AISIX aliases while the gateway holds the Together API key.

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

Before starting, prepare the following:

* One AISIX setup:

  <!-- -->

  * For AISIX Enterprise or AISIX Cloud, an environment with an attached gateway and a write-scoped admin token. For AISIX Enterprise, follow the [AISIX Enterprise getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/aisix-cloud-quickstart.md). To request AISIX Cloud access, [contact API7](https://api7.ai/contact).
  * For the open-source AISIX gateway, prepare either a local AISIX installation or the Docker setup from the [AISIX OSS getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart.md). Configure the gateway to load a declarative resources file.

* A Together API key from the [Together console](https://api.together.ai/settings/api-keys).

* `curl` and `jq`.

## Configure with AISIX Enterprise or AISIX Cloud[​](#configure-with-aisix-enterprise-or-aisix-cloud "Direct link to Configure with AISIX Enterprise or AISIX Cloud")

Export the control-plane connection details:

```
# AISIX_CP is the Admin API base URL; include /api and omit a trailing slash

# The local AISIX Enterprise quickstart uses http://localhost:8080/api

export AISIX_CP="YOUR_AISIX_CONTROL_PLANE_API_URL"

export AISIX_TOKEN="YOUR_ADMIN_TOKEN"

export ENV_ID="YOUR_ENVIRONMENT_ID"
```

Create a provider key, model alias, and caller API key for the Together-backed chat-completions route.

Because Together AI exposes an OpenAI-compatible API, AISIX connects through the `openai` adapter and uses the Together API root as `api_base`.

### Create a Provider Key[​](#create-a-provider-key "Direct link to Create a Provider Key")

Create the provider key that stores the Together credential and API root, and allow it into the environment:

```
# Replace with your value

export TOGETHER_API_KEY="YOUR_PROVIDER_API_KEY"



PROVIDER_KEY_ID=$(curl -sS -X POST "$AISIX_CP/provider_keys" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "together-prod",

    "provider": "togetherai",

    "api_key": "'"${TOGETHER_API_KEY}"'",

    "api_base": "https://api.together.ai/v1",

    "allowed_environments": ["'"$ENV_ID"'"]

  }' | jq -r '.provider_key.id')
```

❶ `provider` is `togetherai`, the catalog provider ID.

❷ `api_key` stores the Together API key. It follows the credential-handling behavior in [Provider Keys](https://docs.api7.ai/ai-gateway/models/provider-keys.md#credential-handling).

❸ `api_base` already includes the `/v1` path. AISIX appends `/chat/completions` to it. Together currently documents `https://api.together.ai/v1`; the control plane still fills in the equivalent `https://api.together.xyz/v1` root when the field is omitted. Set the official root explicitly so the target stays visible on the resource and does not depend on that fallback.

The command captures the returned provider key ID in `PROVIDER_KEY_ID`.

### Create a Model[​](#create-a-model "Direct link to Create a Model")

Together's catalog changes frequently. Look up the exact `<publisher>/<model>` ID in the [Together models list](https://docs.together.ai/docs/serverless/models) before creating a model alias.

Create the model alias callers will send in requests:

```
MODEL_ID=$(curl -sS -X POST "$AISIX_CP/environments/$ENV_ID/models" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "together-gptoss-prod",

    "model_name": "openai/gpt-oss-120b",

    "provider_key_id": "'"$PROVIDER_KEY_ID"'"

  }' | jq -r '.model.id')
```

❶ `display_name` is the alias callers send in `model`.

❷ `model_name` is the Together model ID in `<publisher>/<model>` form. A flat OpenAI-style name such as `gpt-4o` returns a 404 from Together.

❸ `provider_key_id` attaches the alias to the Together provider key.

### Create a Caller API Key[​](#create-a-caller-api-key "Direct link to Create a Caller API Key")

Create the caller API key that can access the model alias. The API generates the key value and returns the plaintext once:

```
AISIX_API_KEY=$(curl -sS -X POST "$AISIX_CP/environments/$ENV_ID/api_keys" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "together-caller",

    "allowed_models": ["'"$MODEL_ID"'"]

  }' | jq -r '.plaintext')
```

The `allowed_models` value references the model by its ID. The plaintext key is returned only in this response, so store it securely.

The new resources project to the attached gateway automatically.

## Configure with AISIX OSS[​](#configure-with-aisix-oss "Direct link to Configure with AISIX OSS")

Export the upstream credential and choose the caller API key that applications will send to the gateway:

```
export TOGETHER_API_KEY="YOUR_PROVIDER_API_KEY"

export CALLER_API_KEY="YOUR_CALLER_API_KEY"

export CALLER_API_KEY_SHA256="$(printf '%s' "$CALLER_API_KEY" | sha256sum | cut -d ' ' -f 1)"
```

For a new gateway, use this complete resources file. For an existing gateway, merge the entries into its [current file](https://docs.api7.ai/ai-gateway/reference/resources-file.md#apply-resource-examples-safely), preserving its other resources:

resources.yaml

```
_format_version: "2"



provider_keys:

  - id: 45f07bf8-71d2-4ee8-9221-28e9ee4464c2

    display_name: "together-prod"

    provider: "togetherai"

    adapter: "openai"

    api_key: ${TOGETHER_API_KEY}

    api_base: "https://api.together.ai/v1"



models:

  - id: 79ace039-0ce9-4643-a387-f46fb22527c5

    display_name: "together-gptoss-prod"

    provider: "togetherai"

    model_name: "openai/gpt-oss-120b"

    provider_key_id: 45f07bf8-71d2-4ee8-9221-28e9ee4464c2



api_keys:

  - id: 09add807-6340-4ea9-ae60-acf66adb1f33

    display_name: "together-caller"

    key_hash: ${CALLER_API_KEY_SHA256}

    allowed_models:

      - "together-gptoss-prod"
```

If AISIX is installed locally, validate the file before loading it:

```
aisix validate --resources resources.yaml
```

After validation, start the gateway with the referenced environment variables in its process environment. Reload an existing gateway only if those variables are already available to the process; otherwise, restart it with the updated environment.

If you use Docker, adapt the validation and startup commands in the [AISIX OSS getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart.md). Mount this `resources.yaml` file and pass every environment variable it references with `-e` in both commands. After the resources load, prepare the shared verification request below:

```
export AISIX_API_KEY="$CALLER_API_KEY"
```

## Verify the Provider Connection[​](#verify-the-provider-connection "Direct link to Verify the Provider Connection")

Export the AISIX gateway origin:

```
# AISIX_PROXY has no trailing slash or endpoint path

# The local quickstarts use http://127.0.0.1:3000

export AISIX_PROXY="YOUR_AISIX_GATEWAY_URL"
```

Send a chat-completions request through the AISIX proxy:

```
curl -sS -X POST "$AISIX_PROXY/v1/chat/completions" \

  -H "Authorization: Bearer ${AISIX_API_KEY}" \

  -H "Content-Type: application/json" \

  -d '{

    "model": "together-gptoss-prod",

    "messages": [

      {

        "role": "user",

        "content": "Say hello from Together AI."

      }

    ]

  }'
```

The gateway returns an OpenAI-compatible response that echoes the caller-facing alias `together-gptoss-prod`. If the request fails, check the provider key `api_key`, `api_base`, and the `<publisher>/<model>` ID in `model_name`.

## Endpoint Coverage[​](#endpoint-coverage "Direct link to Endpoint Coverage")

Together exposes several OpenAI-shaped APIs on the same base, but normalized route support also depends on the model's `togetherai` provider value:

| Route                                                                        | Behavior with a Together AI alias                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/v1/chat/completions`                                                       | Supported, buffered and streaming where the selected model implements the route.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `/v1/completions`                                                            | Supported for buffered responses where the selected model implements the route. Streaming is not available on this route — use `/v1/chat/completions` to stream.                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `/v1/responses`                                                              | Supported through the AISIX [Responses bridge](https://docs.api7.ai/ai-gateway/endpoints/responses-api.md). Together [does not implement a native Responses API](https://docs.together.ai/docs/inference/openai-compatibility), and fields without a chat-completions equivalent are ignored.                                                                                                                                                                                                                                                                                                      |
| `/v1/messages`                                                               | Supported through translation to chat completions. `/v1/messages/count_tokens` is limited to Anthropic-backed models.                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `/v1/embeddings`                                                             | Not currently available with the serverless setup on this page. Together's [serverless model catalog](https://docs.together.ai/docs/serverless/models#embedding-models) lists no embedding models. Dedicated inference uses a different deployment and API base.                                                                                                                                                                                                                                                                                                                                   |
| `/v1/audio/transcriptions`, `/v1/audio/translations`, and `/v1/audio/speech` | Supported when the alias names a Together model for the selected audio route. AISIX preserves the OpenAI request and response shapes while rewriting the model alias.                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `/v1/images/generations`                                                     | Not supported. The normalized route accepts only models whose provider is `openai` or whose provider key uses the `azure-openai` adapter (see [Provider Requirement](https://docs.api7.ai/ai-gateway/endpoints/image-generation.md#provider-requirement)), even though Together serves the same path natively. Use `/passthrough/togetherai/images/generations` instead.                                                                                                                                                                                                                           |
| `/v1/videos`                                                                 | Not supported. The video route's provider allowlist does not include `togetherai`; use a passthrough route with Together's native video contract.                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `/v1/rerank`                                                                 | Not supported. The normalized route accepts only the `openai`, `cohere`, and `jina` provider values. Use `/passthrough/togetherai/rerank` with a Together rerank model and native request body.                                                                                                                                                                                                                                                                                                                                                                                                    |
| `/passthrough/togetherai/*rest`                                              | Available through a configured [passthrough route](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md) for Together-native routes, with limited gateway normalization. Passthrough does not rewrite a caller-facing alias inside the body and relays upstream SSE incrementally. A rerank body with a top-level `query` and a `documents` array records input tokens from the response. For every request shape that records token usage, see [Envelope Detection and Usage](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md#envelope-detection-and-token-usage). |

The `/passthrough/togetherai` paths on this page assume a passthrough route claiming that prefix with Together's API root as its `target_url`; grant the route name on the caller key's `allowed_routes`.

See [Provider Compatibility](https://docs.api7.ai/ai-gateway/providers/compatibility.md) for the full endpoint and provider matrix.

## Next Steps[​](#next-steps "Direct link to Next Steps")

You have now connected AISIX to Together AI and verified the model alias. Continue with these guides:

* [Model Aliases](https://docs.api7.ai/ai-gateway/models/model-aliases.md): configure routing, retry behavior, or cost metadata for this alias.
* [Routing and Failover](https://docs.api7.ai/ai-gateway/routing/routing-and-failover.md): fail over between Together and a second provider.
* [Speech and Audio](https://docs.api7.ai/ai-gateway/endpoints/audio.md): call Together transcription, translation, or text-to-speech models through normalized audio routes.
* [Passthrough Routes](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md): reach Together image, video, rerank, and other native routes.
* [Provider-Specific Overrides](https://docs.api7.ai/ai-gateway/models/provider-keys.md#configure-provider-specific-overrides): adapt request and response shapes when an upstream API differs from its adapter.
* [Provider Compatibility](https://docs.api7.ai/ai-gateway/providers/compatibility.md): review supported proxy endpoints and provider-specific boundaries.
