Endpoint and request
POST https://formalengines.com/inference/v1/chat/completions| Field | Type | Meaning |
|---|---|---|
| model | string · required | A model ID returned by GET /models |
| messages | array · required | Conversation messages, including prior turns you want the model to see |
| max_tokens | integer | Output budget; provider limits and reasoning behavior vary |
| stream | boolean | Set true to receive server-sent events |
| temperature | number | Sampling control, where supported by the model |
| tools / tool_choice | array / string or object | Tool definitions and selection, where supported |
| response_format | object | JSON or structured-output mode, where supported |
Model-specific parameters are passed through where supported. OpenAI-compatible does not mean every model supports every parameter, image format, or endpoint. Use the chat-completions interface shown here; a base-URL change alone does not guarantee support for other SDK APIs such as Responses, audio, or image generation.
Supply conversation history
{
"model": "deepseek-v4-1-flash",
"messages": [
{"role": "system", "content": "You are a concise technical assistant."},
{"role": "user", "content": "What is a database index?"},
{"role": "assistant", "content": "A lookup structure that speeds up data retrieval."},
{"role": "user", "content": "When would I use one?"}
],
"max_tokens": 512
}Each request supplies its own history. The gateway does not carry a conversation forward automatically. Your application or agent manages history, summarization, and tool execution.
Read the response
Read text from choices[0].message.content and tool calls from choices[0].message.tool_calls. Check finish_reason: stop normally indicates completion, length indicates the output limit, and tool_calls means your application should handle a tool request. Usage includes prompt and completion tokens when the provider reports them.
A reasoning model may expose reasoning_content separately from its answer. Do not assume an empty content field means no work occurred. Reserve enough output tokens for the answer and any model reasoning.
SDK extensions versus raw JSON
In the Python SDK, extra_body merges model-specific fields into the request. It is not a wrapper to include in raw curl JSON.
response = client.chat.completions.create(
model="deepseek-v4-1-flash",
messages=[{"role": "user", "content": "Say hello."}],
max_tokens=256,
extra_body={"reasoning": {"enabled": False}},
)In a raw JSON request the equivalent field is "reasoning": {"enabled": false} at the top level. Support and behavior depend on the selected model; disabling reasoning is not a universal guarantee.