API endpoints
SparkAPI exposes three production entrypoints. Pick the one that matches your client, keep the request format that client already uses, and only swap the base URL and API key.
Entrypoints at a glance
Claude / Anthropic
Claude Code, Cline, Anthropic SDK, raw Anthropic Messages.
https://api.sparkapi.cc/api
Header: x-api-key: cr_…
Codex / OpenAI-compatible
Cursor, OpenAI SDK, Chat Completions, Responses API.
https://api.sparkapi.cc/openai/v1
Header: Authorization: Bearer cr_…
Gemini
Google Generative AI SDK, raw Gemini REST calls.
https://api.sparkapi.cc/gemini
Header: Authorization: Bearer cr_…
Routing map
Claude Code / Anthropic SDK
└─ ANTHROPIC_BASE_URL=https://api.sparkapi.cc/api
└─ x-api-key: cr_… → Anthropic Messages
Cursor / OpenAI SDK
└─ base_url=https://api.sparkapi.cc/openai/v1
└─ Authorization: Bearer cr_… → OpenAI Chat / Responses
Gemini SDK / REST
└─ https://api.sparkapi.cc/gemini
└─ Authorization: Bearer cr_… → Google Gemini
| Client family | Base URL | Auth header |
|---|---|---|
| Claude / Anthropic | https://api.sparkapi.cc/api |
x-api-key: cr_... |
| Codex / OpenAI-compatible | https://api.sparkapi.cc/openai/v1 |
Authorization: Bearer cr_... |
| Gemini | https://api.sparkapi.cc/gemini |
Authorization: Bearer cr_... |
Tool setup
Each popular tool needs the base URL and key set in a slightly different place. Use this table as the single source of truth:
| Tool | Base URL field | Key field |
|---|---|---|
| Claude Code (CLI) | ANTHROPIC_BASE_URL=https://api.sparkapi.cc/api |
ANTHROPIC_API_KEY=cr_... |
| Cline (VS Code) | Settings → API Provider → Anthropic → Base URL | Settings → API Provider → API Key |
| Cursor / Codex-compatible tools | Settings → Models → OpenAI API Base | Settings → Models → OpenAI API Key |
| Anthropic SDK (Python / Node) | base_url= or anthropic.baseURL |
api_key= or anthropic.apiKey |
| OpenAI SDK (Python / Node) | base_url= or openai.baseURL |
api_key= or openai.apiKey |
| Gemini SDK / REST | https://api.sparkapi.cc/gemini |
Authorization: Bearer cr_... |
| Raw HTTP (curl, fetch, requests) | use the matching base URL above | matching auth header above |
Examples per tool
Claude Code
export ANTHROPIC_BASE_URL=https://api.sparkapi.cc/api
export ANTHROPIC_API_KEY=cr_your_sparkapi_key
claude
Cline
In VS Code, open the Cline panel → ⚙️ Settings → API Provider: Anthropic. Set:
- Base URL:
https://api.sparkapi.cc/api - API Key: your SparkAPI key
- Model: any from the Models page, e.g.
claude-sonnet-4-6
Anthropic SDK (Python)
import anthropic
client = anthropic.Anthropic(
api_key="cr_your_sparkapi_key",
base_url="https://api.sparkapi.cc/api",
)
OpenAI SDK (Python)
from openai import OpenAI
client = OpenAI(
api_key="cr_your_sparkapi_key",
base_url="https://api.sparkapi.cc/openai/v1",
)
resp = client.chat.completions.create(
model="gpt-5.4",
messages=[{"role": "user", "content": "Hello"}],
)
Gemini REST
curl "https://api.sparkapi.cc/gemini/v1beta/models/gemini-3-flash-preview:generateContent" \
-H "Authorization: Bearer cr_your_sparkapi_key" \
-H "Content-Type: application/json" \
-d '{"contents":[{"parts":[{"text":"hi"}]}]}'
Raw curl (Claude)
curl https://api.sparkapi.cc/api/v1/messages \
-H "x-api-key: cr_your_sparkapi_key" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"claude-sonnet-4-6","max_tokens":32,"messages":[{"role":"user","content":"hi"}]}'
Raw curl (Codex / OpenAI-compatible)
curl https://api.sparkapi.cc/openai/v1/chat/completions \
-H "Authorization: Bearer cr_your_sparkapi_key" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5.4","messages":[{"role":"user","content":"hi"}]}'
Streaming
Claude, Codex-compatible, and Gemini endpoints all support streaming in the same format their upstream clients expect. Pass the normal streaming flag for your client and SparkAPI will proxy it through unchanged.