Developers & integrations
API Integration Guide (OpenAI-Compatible)
Configure environment variables and integrate chat, vision, and retrieval endpoints via cURL, Python, and Node.js.
Updated 2026-11-26 · 3 min read
Unified OpenAI-Compatible Specification
The platform gateway implements the standard OpenAI-compatible HTTPS REST specification with Bearer token authentication. Existing services built with official OpenAI SDKs or standard frameworks migrate cleanly by updating base_url, api_key, and model.
| Capability | Standard Endpoint | Method | Applicable Categories |
|---|---|---|---|
| Text & vision chat | /v1/chat/completions | POST | Text & chat, reasoning, coding, visual understanding |
| Semantic vectors | /v1/embeddings | POST | Embeddings |
| Candidate reranking | /v1/rerank | POST | Reranking |
| Image generation | /v1/images/generations | POST | Image creation |
| Speech synthesis & ASR | /v1/audio/speech · /v1/audio/transcriptions | POST | Speech & audio |
| Enabled model list | /v1/models | GET | Query live model identifiers enabled for your key |
Authentication and Environment Variable Management
Every request requires an Authorization: Bearer ${API_KEY} header. Always inject credentials from a server-side environment variable or secret manager rather than hardcoding strings in source files:
API_BASE_URL: Published platform gateway URL (for examplehttps://api.your-domain.example.com/v1).API_KEY: Server-side secret token issued by the platform console.MODEL_ID: Canonical model identifier listed in Models (such asdeepseek-v3.2orqwen4-max).
Python and Node.js SDK Examples
Configure explicit request timeouts and bounded retries when initializing your SDK client:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["API_KEY"],
base_url=os.environ["API_BASE_URL"],
timeout=60.0,
max_retries=2,
)
completion = client.chat.completions.create(
model="qwen4-max",
messages=[
{"role": "system", "content": "You are a principal backend engineer."},
{"role": "user", "content": "Give three practical timeout and circuit-breaker guidelines."},
],
temperature=0.2,
max_tokens=1024,
)
print(completion.choices[0].message.content)In Node.js / TypeScript backend services, use the standard openai package:
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.API_KEY,
baseURL: process.env.API_BASE_URL,
timeout: 60_000,
maxRetries: 2,
});
const response = await client.chat.completions.create({
model: 'deepseek-v3.2',
messages: [
{ role: 'system', content: 'Answer concisely with actionable engineering steps.' },
{ role: 'user', content: 'Explain common causes of database connection pool exhaustion.' },
],
});
console.log(response.choices[0]?.message.content);Key Request and Response Fields
| Field | Direction | Production Notes |
|---|---|---|
model | Request (required) | Canonical identifier from the catalog, e.g., deepseek-r1 |
messages | Request (required) | Ordered conversation array (system, user, assistant, tool) |
stream | Request (optional) | Set true for interactive UIs to stream SSE tokens |
temperature | Request (optional) | Use 0.0–0.2 for deterministic tasks, 0.6–0.8 for creative drafting |
id | Response | Unique request trace identifier—retain this for support diagnostics |
choices[0].finish_reason | Response | stop (complete), length (hit max_tokens), or tool_calls |
usage | Response | Reports prompt_tokens, completion_tokens, and total_tokens |
Production Security Checklist
- Proxy through your backend: Authenticate end users in your own backend before forwarding requests to the model gateway; never expose raw API keys to browsers.
- Redact logs: Strip
Authorizationheaders and sensitive personal data from application logs. - Handle transient errors: Implement bounded retries and rate-limit handling as documented in Error Codes, Rate Limits & Troubleshooting.