中文

SosoGPT API Docs

OpenAI-compatible API gateway. Available models, groups, routing, and final charges depend on your console configuration and usage logs.

1. Quickstart

Main endpoint:

https://api.sosogpt.com

OpenAI-compatible Base URL:

https://api.sosogpt.com/v1
EndpointPurpose
GET /v1/modelsList models available to the current API key.
POST /v1/chat/completionsOpenAI Chat Completions format.
POST /v1/responsesOpenAI Responses format.
POST /v1/messagesAnthropic-compatible Messages format for Claude Code.

2. Create and Use API Keys

  1. Sign in to the console.
  2. Open Token Management.
  3. Create an API key and choose the group you need.
  4. Save the key. The full key is usually shown only once.
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Do not expose API keys in frontend code, public repositories, or client packages. Delete and recreate leaked keys immediately.

3. Models

Different token groups may see different model lists. Query available models with your own API key:

curl https://api.sosogpt.com/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY"

Model names must match the returned names exactly, including case, hyphens, and version suffixes.

4. Examples

Chat Completions

curl https://api.sosogpt.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [
      {
        "role": "user",
        "content": "Introduce yourself in one sentence"
      }
    ],
    "stream": false
  }'

Streaming

curl https://api.sosogpt.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [
      {
        "role": "user",
        "content": "Write a short product intro"
      }
    ],
    "stream": true
  }'

Node.js SDK

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.SOSOGPT_API_KEY,
  baseURL: "https://api.sosogpt.com/v1",
});

const completion = await client.chat.completions.create({
  model: "gpt-5.4-mini",
  messages: [{ role: "user", content: "Hello, introduce yourself" }],
});

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

Python SDK

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.sosogpt.com/v1"
)

response = client.chat.completions.create(
    model="gpt-5.4-mini",
    messages=[
        {"role": "user", "content": "Hello, introduce yourself"}
    ]
)

print(response.choices[0].message.content)

5. Codex CLI and Claude Code

Create an API key first and make sure its group has access to the model you want.

CLI Prerequisites

Codex CLI and Claude Code require Node.js and npm. Use the current LTS version.

node -v
npm -v

Linux or macOS with nvm:

curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
source ~/.bashrc
nvm install --lts
nvm use --lts
node -v
npm -v

Windows PowerShell:

winget install -e --id OpenJS.NodeJS.LTS
node -v
npm -v

Codex CLI

npm i -g @openai/codex
codex --version

Create the config directory:

mkdir -p ~/.codex
chmod 700 ~/.codex

Create or edit ~/.codex/config.toml:

model_provider = "sosogpt"
model = "gpt-5.5"
model_reasoning_effort = "medium"
disable_response_storage = true
cli_auth_credentials_store = "file"

[model_providers.sosogpt]
name = "SosoGPT"
base_url = "https://api.sosogpt.com/v1"
wire_api = "responses"
requires_openai_auth = true

Current Codex Base URL:

https://api.sosogpt.com/v1

Create or edit ~/.codex/auth.json and replace YOUR_API_KEY:

{
  "OPENAI_API_KEY": "YOUR_API_KEY"
}
codex
codex -m gpt-5.5
codex -m gpt-5.4-mini

Claude Code

Claude Code uses the Anthropic protocol, not OpenAI Chat Completions. SosoGPT provides an Anthropic-compatible endpoint.

npm i -g @anthropic-ai/claude-code
claude --version
mkdir -p ~/.claude
chmod 700 ~/.claude

Create or edit ~/.claude/settings.json and replace YOUR_API_KEY:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_BASE_URL": "https://api.sosogpt.com"
  }
}

Current Claude Code Base URL:

https://api.sosogpt.com
claude

Use CC Switch to Manage Keys

CC Switch can manage providers and keys for Claude Code, Codex, OpenAI-compatible clients, or multiple API keys.

https://github.com/farion1231/cc-switch/releases

Auto Import CC Switch Configuration

  1. Open Token Management in the SosoGPT console.
  2. Create an API key for your local client and choose the desired group.
  3. Find the Chat button on the right side of the token row.
  4. Open the dropdown next to Chat and choose CC Switch.
  5. Your browser will launch CC Switch and import the endpoint, key, and provider configuration.
  6. Confirm that the SosoGPT provider is active, then return to the corresponding client.

Manual CC Switch Configuration

NameSosoGPT
ApplicationChoose the actual client, such as Claude Code or Codex.
Base URLClaude Code: https://api.sosogpt.com; Codex / OpenAI-compatible clients: https://api.sosogpt.com/v1
API Key / Auth TokenUse the API key created in the SosoGPT console.
ModelChoose a model available to the current token group, for example claude-sonnet-4-6, gpt-5.5, or gpt-5.4-mini.
claude
codex

6. Groups and Billing

SosoGPT uses token groups to control model access, routing, and billing ratios. Different groups may have different routes, models, and prices.

Marketplace prices are references. Final charges are based on console usage logs.

7. Common Errors

ErrorLikely CauseAction
401 UnauthorizedMissing or invalid API keyCheck Authorization: Bearer YOUR_API_KEY.
404 Invalid URLWrong pathUse /v1/chat/completions, /v1/responses, or /v1/messages.
429 Too Many RequestsRate limit, insufficient balance, or quota limitRetry later or check balance and token limits.
500 / 502 / 503Upstream route issue, model unavailable, or network fluctuationRetry later or switch model/group if needed.

When reporting issues, keep the Request ID, model name, request time, and full error message.