Docs contents

OpenAI-compatible API (Chat Completions)

Call models through POST /v1/chat/completions on GoiAPI, compatible with OpenAI SDKs and tools; request body, streaming and how to change the base URL.

Ask AI and more
View as Markdown

An endpoint compatible with OpenAI Chat Completions. Tools and libraries built for the OpenAI API only need the base URL set to https://api.goiapi.com/v1 and your API key.

HTTP
POST https://api.goiapi.com/v1/chat/completions

Body

The body is JSON in the OpenAI Chat Completions format. Required fields:

  • model: the model name, listed on Models or returned by GET /v1/models. Model aliases work too.
  • messages: the list of messages.

Set max_tokens (or max_completion_tokens). Funds are reserved based on this value before the model is called, so keeping it no higher than you need prevents requests from being rejected when your balance is low. See Limits and balance.

Terminal
curl https://api.goiapi.com/v1/chat/completions \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-5-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Write a Python function that reverses a string"}]
  }'

Response

Without streaming: a Chat Completions JSON response (choices, usage, and so on).

With streaming ("stream": true): see Streaming. For OpenAI-format requests, stream_options.include_usage is always enabled, so the stream ends with an extra chunk that contains usage.

Notes

  • Tools that use the OpenAI Responses API (recent Codex CLI versions, client.responses.create()) call /v1/responses.
  • Every response includes an x-request-id header. Send this ID to support when you need a request looked up.
  • For Claude models, prefer the Anthropic format (for example with Claude Code). Some models are only available through one format; calling a model through a format it does not support returns a 503 error.