API Docs
Get Started

5-Minute Quickstart

Make your first model API call with UnioAPI. Create an API key, choose an OpenAI-compatible or Anthropic-compatible endpoint, and run a request example.

Prerequisites

  • A console account with a balance: new accounts start at zero, and without a top-up the very first request returns 402. The full top-up and key steps are in Console & top-up.
  • curl, or the official Python / Node.js SDKs.

1. Get an API Key

Create an API key under Access → API Keys in the console. One key covers every model on sale.

Create key form: name, spend cap and expiry
public/docs/screenshots/console-create-key.png · 1600×1000
export UNIO_API_KEY="sk-unio-..."

The key is shown in full only once — store it safely and never commit it to a repository.

2. Point at the unified entry

Change the base URL of your existing code or tool to:

https://api.unioapi.com
  • OpenAI-compatible clients usually take https://api.unioapi.com/v1;
  • Anthropic-compatible clients (such as Claude Code) take https://api.unioapi.com.

Request shapes, SDKs, and calling habits stay the same.

3. Make your first call

OpenAI-compatible (Chat Completions):

curl https://api.unioapi.com/v1/chat/completions \
  -H "Authorization: Bearer $UNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-sol",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Anthropic-compatible (Messages):

curl https://api.unioapi.com/v1/messages \
  -H "x-api-key: $UNIO_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Responses (OpenAI's newer interface; models such as gpt-5.5-pro only support it):

curl https://api.unioapi.com/v1/responses \
  -H "Authorization: Bearer $UNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-sol",
    "input": "Hello"
  }'

A 200 response means you are connected. The model field echoes the Unio model identifier you requested:

{
  "object": "chat.completion",
  "model": "gpt-5.6-sol",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Hello! ..." },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 8, "completion_tokens": 12, "total_tokens": 20 }
}

4. Turn on streaming

Add "stream": true to the body and the result arrives as SSE events — good for chat UIs and long outputs:

curl -N https://api.unioapi.com/v1/chat/completions \
  -H "Authorization: Bearer $UNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-5.6-sol", "stream": true, "messages": [{"role": "user", "content": "Hello"}]}'

Event formats for all three endpoints are in Streaming.

5. Let your tools find the key

Most SDKs and coding tools read the address and key from environment variables. Put them in your shell profile:

# OpenAI-style SDKs and tools
export OPENAI_BASE_URL=https://api.unioapi.com/v1
export OPENAI_API_KEY="$UNIO_API_KEY"

# Anthropic-style SDKs and Claude Code
export ANTHROPIC_BASE_URL=https://api.unioapi.com
export ANTHROPIC_AUTH_TOKEN="$UNIO_API_KEY"

FAQ

SymptomCause
401The key is incomplete, not loaded, or revoked
402Balance too low — top up first; or the key reached its spend cap
404The /v1 in the base URL doesn't match the protocol, or the model ID is wrong
400 context_length_exceededThe input exceeds the model's context window

More cases in FAQ & Troubleshooting.

Next steps