Text Generation

The gateway exposes the following public text entrypoints. Prefer POST /v1/responses for new integrations, and use the others for SDK compatibility or native Claude clients.

ProtocolMethod and pathUse
OpenAIPOST /v1/responsesPreferred unified text generation API for new projects
OpenAIPOST /v1/chat/completionsWidely compatible chat completion endpoint
OpenAIPOST /v1/completionsLegacy text completions, only for compatibility
AnthropicPOST /v1/messagesClaude native message format
OpenAIGET /v1/modelsList logical models available under the current routing

OpenAI Responses

bash
curl https://api.modelgo.ai/v1/responses \
  -H "Authorization: Bearer $MODELGO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model":"<model>",
    "input":"Introduce ModelGo in three sentences."
  }'

Use this entrypoint when you want a single OpenAI-compatible response API with a forward-looking request shape.

OpenAI Chat Completions compatibility

bash
curl https://api.modelgo.ai/v1/chat/completions \
  -H "Authorization: Bearer $MODELGO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model":"<model>",
    "messages":[{"role":"user","content":"hello"}]
  }'

Use this for existing OpenAI SDK flows that still depend on chat completions. New projects should usually start from POST /v1/responses.

OpenAI Completions (legacy)

bash
curl https://api.modelgo.ai/v1/completions \
  -H "Authorization: Bearer $MODELGO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model":"<model>",
    "prompt":"Introduce ModelGo in three sentences.",
    "max_tokens":256
  }'

The legacy text-completions endpoint, only for call chains that still use a prompt. New projects should use Responses or Chat Completions above. stream is likewise delivered over SSE. Most current chat models do not offer this protocol: qwen3.6-flash returns HTTP 400 model_protocol_not_offered.

Anthropic Messages

bash
curl https://api.modelgo.ai/v1/messages \
  -H "x-api-key: $MODELGO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model":"<model>",
    "max_tokens":1024,
    "messages":[{"role":"user","content":"hello"}]
  }'

Use this when the client already speaks Claude's native /v1/messages schema. The gateway preserves the native event-stream framing for streamed Anthropic responses.

Listing models

bash
curl https://api.modelgo.ai/v1/models \
  -H "Authorization: Bearer $MODELGO_API_KEY"

GET /v1/models returns the logical models allowed by the API key's bound policy (resolved against the platform model catalog). It does not probe upstream capabilities at request time and may differ from the console; billing and policy follow the console and bound policies.

Key conventions

  • model must be the platform logical model name.
  • GET /v1/models is available; the list is derived from the API key's bound policy and the platform model catalog.
  • Both OpenAI and Anthropic style endpoints may return upstream-native usage.
  • Stream failures may arrive as error chunks; do not rely only on data: [DONE].

See Authentication and Errors & Rate Limits.