Skip to content

Quickstart

Three steps to your first request: get a key, set the Base URL, call the API.

1. Get an API key

Sign in to the console and create a key: https://swato.ai/login.

A key looks like sk-.... Every key belongs to a group, and the group's platform (OpenAI / Anthropic / Google) determines which protocol surface you use. See Authentication.

Put the key in an environment variable; the examples below read from it:

bash
export SWATOWAPI_KEY="sk-..."

2. Base URLs

Pick the Base URL that matches your key's group platform:

Protocol surfaceBase URLEnv var
OpenAI-compatiblehttps://swato.ai/v1OPENAI_BASE_URL
Anthropic-compatiblehttps://swato.aiANTHROPIC_BASE_URL (client appends /v1/messages)
Gemini-compatiblehttps://swato.ai/v1betaGemini SDK / CLI

TIP

Domestic (汕拓智算) users use the domestic console's own origin as the Base URL; the path structure is identical. This guide uses https://swato.ai as the example origin.

3. Your first request

The following makes a Chat Completions call to https://swato.ai/v1/chat/completions. Authenticate with the Authorization: Bearer $SWATOWAPI_KEY header.

bash
curl https://swato.ai/v1/chat/completions \
  -H "Authorization: Bearer $SWATOWAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [
      { "role": "user", "content": "Say hello in one sentence." }
    ]
  }'
python
# pip install openai
from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["SWATOWAPI_KEY"],
    base_url="https://swato.ai/v1",
)

resp = client.chat.completions.create(
    model="gpt-5.5",  # illustrative; exact ids: GET /v1/models
    messages=[
        {"role": "user", "content": "Say hello in one sentence."},
    ],
)

print(resp.choices[0].message.content)
js
// npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.SWATOWAPI_KEY,
  baseURL: "https://swato.ai/v1",
});

const resp = await client.chat.completions.create({
  model: "gpt-5.5", // illustrative; exact ids: GET /v1/models
  messages: [
    { role: "user", content: "Say hello in one sentence." },
  ],
});

console.log(resp.choices[0].message.content);

TIP

The gpt-5.5 above is illustrative. For the exact model id, call GET /v1/models and use what the server returns.

Anthropic-style clients

If you use the Anthropic SDK, set ANTHROPIC_BASE_URL to https://swato.ai and the client calls /v1/messages. Note: this requires a key whose group platform is Anthropic.

bash
curl https://swato.ai/v1/messages \
  -H "Authorization: Bearer $SWATOWAPI_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-8",
    "max_tokens": 256,
    "messages": [
      { "role": "user", "content": "Say hello in one sentence." }
    ]
  }'

Streaming

Add "stream": true to the request body to receive the response in chunks over server-sent events (SSE). Supported on both the OpenAI and Anthropic surfaces:

bash
curl https://swato.ai/v1/chat/completions \
  -H "Authorization: Bearer $SWATOWAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "stream": true,
    "messages": [{ "role": "user", "content": "Tell me a short joke." }]
  }'

Next steps