Skip to main content

Together AI

Connect AISIX AI Gateway to Together AI so applications can call Together-hosted open-source models through the gateway's OpenAI-compatible API. AISIX keeps the Together credential on the gateway side. It authorizes model access with caller API keys and allowlists, and applies the same rate-limit and usage-accounting controls as other model aliases.

Together AI exposes an OpenAI-compatible API, so it uses the openai adapter with a Together api_base.

Prerequisites

The following examples use a self-hosted AISIX gateway. Before configuring the upstream, prepare the following:

Configure the Together Upstream

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

Create a Provider Key

Create the provider key that stores the Together credential and API root:

# Replace with your values
export AISIX_ADMIN_KEY="YOUR_ADMIN_KEY"
export TOGETHER_API_KEY="YOUR_PROVIDER_API_KEY"

curl -sS -X POST "http://127.0.0.1:3001/admin/v1/provider_keys" \
-H "Authorization: Bearer ${AISIX_ADMIN_KEY}" \
-H "Content-Type: application/json" \
--data-binary @- <<EOF
{
"display_name": "together-prod",
"provider": "together",
"adapter": "openai",
"secret": "${TOGETHER_API_KEY}",
"api_base": "https://api.together.xyz/v1"
}
EOF

provider is together.

adapter is openai, because Together accepts OpenAI chat-completions requests.

secret stores the Together API key. It follows the credential-handling behavior in Provider Credentials.

api_base is required and already includes the /v1 path. AISIX appends /chat/completions to it.

Copy the returned provider key ID.

Create a Model

Together's catalog changes frequently. Look up the exact <publisher>/<model> ID in the Together models list before creating a model alias.

Create the model alias callers will send in requests:

# Replace with your values
export PROVIDER_KEY_ID="YOUR_PROVIDER_KEY_ID"

curl -sS -X POST "http://127.0.0.1:3001/admin/v1/models" \
-H "Authorization: Bearer ${AISIX_ADMIN_KEY}" \
-H "Content-Type: application/json" \
--data-binary @- <<EOF
{
"display_name": "together-gptoss-prod",
"provider": "together",
"model_name": "openai/gpt-oss-120b",
"provider_key_id": "${PROVIDER_KEY_ID}"
}
EOF

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

Choose the caller API key value that the application will send to AISIX, then hash it for the admin resource:

# Replace with your values
export AISIX_API_KEY="YOUR_CALLER_API_KEY"

CALLER_KEY_HASH=$(printf '%s' "${AISIX_API_KEY}" | shasum -a 256 | awk '{print $1}')

Create the caller API key resource that can access the model alias:

curl -sS -X POST "http://127.0.0.1:3001/admin/v1/apikeys" \
-H "Authorization: Bearer ${AISIX_ADMIN_KEY}" \
-H "Content-Type: application/json" \
--data-binary @- <<EOF
{
"key_hash": "${CALLER_KEY_HASH}",
"allowed_models": ["together-gptoss-prod"]
}
EOF

The allowed_models value must match the model alias you created.

Verify the Provider Connection

Send a chat-completions request through the AISIX proxy:

curl -sS -X POST "http://127.0.0.1:3000/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 secret, api_base, and the <publisher>/<model> ID in model_name.

Next Steps

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