Quickstart
Create an API key, install the CLI, and run your first inference request.
Developer quickstart
The Inference API is an OpenAI-shaped surface, with realtime, flex, and batch processing modes for anything from an interactive request a user is waiting on to an overnight batch job. The fastest path is the sference CLI; use the Python SDK or raw HTTP when you need them in your stack.
Control plane vs inference
- Inference (
https://api.sference.com/v1/...): models, batches, responses, streams, plus read-only billing and usage. Authenticated with your API key. - Control plane (
/control/v1/...in API Reference): orgs, API keys, catalog. Serves the console session; API keys are not accepted there.
This page focuses on inference. Keys are minted in the sference console.
Get a key
Create an account at app.sference.com and generate a key under API Keys (app.sference.com/api-keys).
Store the key somewhere safe (password manager, Doppler, Vault, …). Never commit it to git. Export it for local development:
export SFERENCE_API_KEY="sk_..."On Windows (PowerShell), setx writes the variable for future sessions and does not update the one you are in. Set it for the current session as well:
setx SFERENCE_API_KEY "sk_..."
$env:SFERENCE_API_KEY = "sk_..."The CLI and the snippets below read SFERENCE_API_KEY from the environment.
Install the CLI
curl -fsSL https://raw.githubusercontent.com/s-ference/sference/main/install.sh | shOther options: uv tool install sference-cli, pip install sference-cli, or pipx install sference-cli. See CLI for details.
Run your first request
Start with a realtime request, a synchronous call that returns when inference finishes. It is OpenAI-shaped, so if you already call /v1/chat/completions somewhere, only the base URL and the model id change. The OpenAI Python and Node SDKs need base_url / baseURL set to https://api.sference.com/v1. The model id below is filled from the live catalog: a current text model that accepts enable_thinking: false.
Thinking is on by default
Thinking is on by default, and reasoning tokens count toward max_tokens. A small cap can finish during reasoning and come back with empty content. With structured output, models other than GLM (for example DeepSeek V4) default thinking off.
On chat completions, turn thinking off with enable_thinking: false or reasoning_effort: "none". On /v1/messages, send thinking: {"type": "disabled"}. chat_template_kwargs is ignored, not rejected.
The GLM 5.3 family, including GLM 5.3 Flash, cannot turn thinking off and returns 400. The zai-org/GLM-5.2 alias is served by those same weights, so it returns 400 too. That alias is the CLI default for Codex, opencode, and Pi. On those models, set reasoning_effort to "low" on chat completions, or raise max_tokens.
The first example uses a current non-GLM model and sets enable_thinking to false.
OpenAI Python SDK:
pip install openaiOpenAI Node SDK:
npm install openaicurl https://api.sference.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $SFERENCE_API_KEY" \ -d '{ "model": "deepseek-ai/DeepSeek-V4.1-Flash-1017", "messages": [ { "role": "user", "content": "Write a one-sentence greeting for an inference platform." } ], "enable_thinking": false }'import osfrom openai import OpenAIclient = OpenAI( base_url="https://api.sference.com/v1", api_key=os.environ["SFERENCE_API_KEY"],)response = client.chat.completions.create( model="deepseek-ai/DeepSeek-V4.1-Flash-1017", messages=[ {"role": "user", "content": "Write a one-sentence greeting for an inference platform."}, ], extra_body={"enable_thinking": False},)print(response.choices[0].message.content)import OpenAI from "openai";const client = new OpenAI({ baseURL: "https://api.sference.com/v1", apiKey: process.env.SFERENCE_API_KEY,});const response = await client.chat.completions.create({ model: "deepseek-ai/DeepSeek-V4.1-Flash-1017", messages: [ { role: "user", content: "Write a one-sentence greeting for an inference platform." }, ], enable_thinking: false,} as OpenAI.Chat.ChatCompletionCreateParamsNonStreaming);console.log(response.choices[0]?.message.content);The TypeScript sample uses top-level await. Save as quickstart.mts and run with npx tsx quickstart.mts. The cast is only there so the OpenAI types compile. enable_thinking is still sent on the JSON body.
Add "stream": true to receive tokens as they are produced rather than waiting for the full completion.
The same thing from the CLI
Sign the CLI in (if you have not already). sference auth login opens the console to approve this device; in scripts, use --api-key with the key you created above:
sference auth login
# or, non-interactive:
sference auth login --api-key "$SFERENCE_API_KEY"sference responses create \
--model "deepseek-ai/DeepSeek-V4.1-Flash-1017" \
--content "Write a one-sentence greeting for an inference platform." \
--wait--wait returns the finished result instead of a response id. Add --json for machine-readable output. For batches, streams, and JSONL jobs, see CLI and the OSS README.
Realtime, flex, or batch?
The example above runs on the realtime mode, a synchronous request that returns when inference finishes. All modes share the same endpoint, models, and fleet:
| Mode | How | When |
|---|---|---|
| Realtime | Sync /v1/chat/completions, /v1/messages, or blocking /v1/responses | A user is waiting on the response |
| Priority | /v1/chat/completions or /v1/responses with service_tier: "priority" (priority-enabled orgs; not /v1/messages) | Latency-critical requests under congestion; jumps the pending queue at 1.3 × list |
| Flex | /v1/chat/completions or /v1/responses with service_tier: "flex" (not /v1/messages) | Latency-tolerant sync work at a discount; may queue longer, retries on 408 |
| Batch | background: true on /v1/responses, streams, batches | Large jobs, evals, and offline pipelines on the 24h completion window |
Python SDK
For application code or coding agents:
pip install sference-sdkFor interactive code, call the blocking response/chat methods; for unattended jobs, use create_response(..., background=True) with wait_for_response; see Python SDK.
Background work with raw HTTP
When nobody is waiting on the result, whether bulk jobs, long generations, or anything off the interactive path, send it to /v1/responses with background: true and collect it later:
curl https://api.sference.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SFERENCE_API_KEY" \
-d '{
"model": "deepseek-ai/DeepSeek-V4.1-Flash-1017",
"input": [
{ "role": "user", "content": "Write a one-sentence greeting for an inference platform." }
],
"background": true
}'You get a response object with an id and status (in_progress, completed, failed, …). Poll GET /v1/responses/{response_id} or use events; see OpenAI Responses API.
Go deeper
CLI
Install, auth, batches, streams, and responses subcommands.
Python SDK
Library usage and copy-paste prompts for Cursor and Claude Code.
Anthropic Messages API
Already have Anthropic-shaped code? Change the base URL and the model id.
Models
Choosing a tier, pinning versions, and browsing the catalog.
Batch API
Thousands of rows on the 24h window, not a single prompt.
API Reference
OpenAPI-backed pages for every operation.
Overview
Inference for realtime AI and long-running AI agents: an OpenAI-compatible API with realtime, priority, flex, and batch windows on one fleet. Quickstart, models, pricing, and full HTTP reference.
Models
The sference catalog: how to choose a model, pin a version, read capabilities from the API, and bring your own weights.