Your first API call
Connect an agent to DSSUB or make a Chat Completions request with cURL, Python or Node.js.
On this page
Current availabilityConnect an agentGet your connection detailsSet environment variablesSend a requestRead the responseKeep buildingCurrent availability#
DSSUB is a design preview. Account, payment and API services are not connected. The examples and expected behavior below are integration references, not a verified production contract. A .invalid endpoint cannot accept real requests.
Connect an agent#
Create an API key, then follow the setup guide for your client.
- Claude Code uses Anthropic Messages.
- Codex uses the Responses API.
- OpenCode, OpenClaw, Hermes Agent, DeepSeek Harness and Pi use Chat Completions.
Get your connection details#
Keep these three values from the same provider. A subscription key cannot automatically be used with the official DeepSeek endpoint.
| Setting | What to use |
|---|---|
| API key | A key issued by your API provider |
| Base URL | The provider's OpenAI-compatible API base, including any required version prefix |
| Model | The exact model ID enabled for your account |
The API keys preview contains sample data only. https://api.dssub.invalid/v1 is an example base, not a real connection. Wait for verified connection details and an authorized key before sending a request.
Set environment variables#
macOS / Linux
Set these in the terminal where you will run your code. Include a version prefix such as /v1 only if your provider requires it; omit the final slash.
export DSSUB_API_KEY="your-api-key"
export DSSUB_BASE_URL="https://your-provider.example/v1"
export DSSUB_MODEL="deepseek-flash"Windows PowerShell
$env:DSSUB_API_KEY = "your-api-key"
$env:DSSUB_BASE_URL = "https://your-provider.example/v1"
$env:DSSUB_MODEL = "deepseek-flash"Environment variables apply to the current terminal session. Run the Python or Node.js example below in that same terminal on either platform. The cURL example uses macOS / Linux shell syntax.
Send a request#
Choose a language. Python requires python -m pip install openai; Node.js requires npm install openai and an .mjs file. These examples send one short request, which may consume allowance.
curl --fail-with-body "$DSSUB_BASE_URL/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DSSUB_API_KEY" \
-d "{\"model\":\"$DSSUB_MODEL\",\"messages\":[{\"role\":\"user\",\"content\":\"Say hello in one sentence.\"}],\"stream\":false}"import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["DSSUB_API_KEY"],
base_url=os.environ["DSSUB_BASE_URL"],
)
response = client.chat.completions.create(
model=os.environ["DSSUB_MODEL"],
messages=[{"role": "user", "content": "Say hello in one sentence."}],
stream=False,
)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.DSSUB_API_KEY,
baseURL: process.env.DSSUB_BASE_URL,
});
const response = await client.chat.completions.create({
model: process.env.DSSUB_MODEL,
messages: [{ role: "user", content: "Say hello in one sentence." }],
stream: false,
});
console.log(response.choices[0].message.content);Read the response#
The assistant's answer is in choices[0].message.content. Below is an illustrative excerpt; actual text and token counts vary.
{
"choices": [{
"message": { "role": "assistant", "content": "Hello! How can I help?" },
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 12, "completion_tokens": 8, "total_tokens": 20 }
}Check the returned usage fields against Usage and your plan windows. Pending requests may temporarily reserve allowance or credit until settled.
If the request fails, use the HTTP status and response message with the error guide. Check the endpoint path before changing your key.
Keep building#
- Stream a response to display text as it arrives.
- Continue a conversation by sending message history.
- Understand token usage before scaling up requests.
Official provider keys and connection settings belong to the official service. See models and API compatibility for the distinction.
Guide updated November 11, 2026 · All tutorials