AI Gateway API — Agentuity Documentation

AI Gateway API

List supported LLM models and run routed AI Gateway completions

https://aigateway-usw.agentuity.cloud

Authentication

Most requests require a Bearer token. Pass your API or SDK key in the Authorization header. Public endpoints are noted below and do not require authentication.

HeaderValue
AuthorizationBearer YOUR_SDK_KEY

You can find your SDK key in the Agentuity Console under your project settings.


List Models

List model metadata for LLM providers available through AI Gateway, grouped by provider.

GET/models
https://aigateway-usw.agentuity.cloud/models

Authentication: Public. No auth required.

Response

JSON response with provider keys mapped to arrays of supported model metadata under the data envelope.

StatusDescription
200Model catalog returned. Public — no auth required.

Response Fields

FieldTypeDescription
successboolean
dataobject (optional)
messagestring (optional)
errorstring (optional)

Example

curl -X GET 'https://aigateway-usw.agentuity.cloud/models' \
  -H 'Authorization: Bearer $AGENTUITY_SDK_KEY'

Create Completion

Create a completion through the AI Gateway auto-router. The gateway routes by model and request shape, so chat messages and legacy prompt payloads are both supported.

POST/
https://aigateway-usw.agentuity.cloud/

Request Body

Completion request. Use messages for chat-compatible models and prompt for legacy OpenAI completions-compatible models. Additional provider-specific fields are passed through.

FieldTypeDescription
modelstringModel to use for the completion.
inputanyResponses-compatible input payload for models using the Responses API. (optional)
contentsarrayGoogle Generative AI contents payload. (optional)
messagesobject[]Messages to complete. (optional)
messages[].rolestring
messages[].contentstring | object[] | null (optional)
messages[].namestring (optional)
messages[].tool_call_idstring (optional)
messages[].tool_callsarray (optional)
promptstring | string[]Prompt to complete. (optional)
temperaturenumber (optional)
top_pnumber (optional)
max_tokensnumber (optional)
streamboolean (optional)
stopstring | string[] (optional)

Response

Provider-compatible completion response.

StatusDescription
200Completion created
400Invalid completion request
401Unauthorized — invalid or missing API key
402Payment required — upgrade to a paid plan

Response Headers

HeaderDescription
X-Gateway-CostEstimated total gateway cost in USD, when billing metadata is available.
X-Gateway-Prompt-TokensPrompt token count used for gateway billing.
X-Gateway-Completion-TokensCompletion token count used for gateway billing.

Response Fields

FieldTypeDescription
idstring
objectstring
creatednumber
modelstring
choicesarray
usageany
agentuityobjectAgentuity AI Gateway metadata.
agentuity.headersobjectAI Gateway response headers captured from the HTTP response.
agentuity.costobjectParsed AI Gateway cost information when available.
agentuity.cost.totalnumberTotal estimated gateway cost in USD.
agentuity.cost.unitstringGateway billing unit.
agentuity.cost.inputQuantitynumberInput quantity used for non-token gateway billing.
agentuity.cost.outputQuantitynumberOutput quantity used for non-token gateway billing.
agentuity.cost.promptTokensnumberPrompt token count used for gateway billing.
agentuity.cost.completionTokensnumberCompletion token count used for gateway billing.
agentuity.cost.reasoningTokensnumberReasoning token count reported by the model provider when available.

Example

curl -X POST 'https://aigateway-usw.agentuity.cloud/' \
  -H 'Authorization: Bearer $AGENTUITY_SDK_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "openai/gpt-4o-mini",
  "messages": [
    {
      "role": "user",
      "content": "Say hello in one sentence."
    }
  ],
  "max_tokens": 64
}'

Stream Completion

Create a streaming completion through the AI Gateway auto-router. Set stream: true to receive Server-Sent Events token deltas.

POST/
https://aigateway-usw.agentuity.cloud/

Request Body

Completion request with stream set to true.

FieldTypeDescription
modelstringModel to use for the completion.
inputanyResponses-compatible input payload for models using the Responses API. (optional)
contentsarrayGoogle Generative AI contents payload. (optional)
messagesobject[]Messages to complete. (optional)
messages[].rolestring
messages[].contentstring | object[] | null (optional)
messages[].namestring (optional)
messages[].tool_call_idstring (optional)
messages[].tool_callsarray (optional)
promptstring | string[]Prompt to complete. (optional)
temperaturenumber (optional)
top_pnumber (optional)
max_tokensnumber (optional)
streamtrueEnable Server-Sent Events streaming.
stopstring | string[] (optional)

Response

Server-Sent Events stream. Each data: frame contains a provider-compatible delta payload. The stream ends with data: [DONE].

StatusDescription
200Streaming completion started
400Invalid completion request
401Unauthorized — invalid or missing API key
402Payment required — upgrade to a paid plan

Response Headers

HeaderDescription
TrailerDeclares billing trailers such as X-Gateway-Cost, X-Gateway-Prompt-Tokens, and X-Gateway-Completion-Tokens for streamed responses.
X-Gateway-CostEstimated total gateway cost in USD. For streaming responses this may be delivered as an HTTP trailer after the body completes.
X-Gateway-Prompt-TokensPrompt token count used for gateway billing. For streaming responses this may be delivered as an HTTP trailer.
X-Gateway-Completion-TokensCompletion token count used for gateway billing. For streaming responses this may be delivered as an HTTP trailer.

Response Fields

FieldTypeDescription
choicesobject[]Streamed completion choices.
choices[].deltaobjectIncremental assistant message content.
choices[].delta.rolestringRole for the streamed message delta.
choices[].delta.contentstringToken or text delta.
choices[].finish_reasonstring | nullReason the model stopped generating, when available.

Example

curl -X POST 'https://aigateway-usw.agentuity.cloud/' \
  -H 'Authorization: Bearer $AGENTUITY_SDK_KEY' \
  -H 'Accept: text/event-stream' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "openai/gpt-4o-mini",
  "messages": [
    {
      "role": "user",
      "content": "Count to three."
    }
  ],
  "stream": true
}'