OpenAI-compatible API
Point the OpenAI SDK at Inference Cloud, or call the HTTP endpoints directly. Chat completions, streaming, tools, and model listing are available.
Endpoints
https://inferenceapi.wethinkdigital.solutions/v1/chat/completionsCreate a chat completion. Supports streaming with server-sent events.
https://inferenceapi.wethinkdigital.solutions/v1/modelsList the active model catalog available to your account.
https://inferenceapi.wethinkdigital.solutions/v1/models/{model}Retrieve a single model, including limits and capabilities.
Use the base URL override
baseURL to https://inferenceapi.wethinkdigital.solutions/v1. The SDK appends /chat/completions automatically.Chat completions
The request body follows the OpenAI chat completions schema. model must be a platform model ID. Retrieve valid IDs from GET /v1/models or the Models page in the console.
curl https://inferenceapi.wethinkdigital.solutions/v1/chat/completions \
-H "Authorization: Bearer sk_live_xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "model-pro",
"messages": [
{
"role": "system",
"content": "You are a concise technical assistant."
},
{
"role": "user",
"content": "Summarize the CAP theorem in two sentences."
}
],
"max_tokens": 256,
"temperature": 0.4
}'Core parameters
| Field | Type | Description |
|---|---|---|
| model | string | Required. A platform model ID from the active catalog. |
| messages | array | Required. Ordered conversation turns with role and content. System, user, and assistant roles are supported. |
| max_tokens | integer | Optional. Upper bound on generated output tokens. Defaults and limits depend on the model. |
| temperature | number | Optional. Sampling temperature. Supported range is model-dependent. |
| stream | boolean | Optional. When true, the response is an SSE stream of chat.completion.chunk objects. |
| tools | array | Optional. Tool definitions. Only available when the model capability reports tools support. |
Streaming
Set stream: true to receive server-sent events. Each event contains a chat.completion.chunk with incremental content in choices[0].delta. The stream terminates with data: [DONE].
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.INFERENCE_API_KEY,
baseURL: "https://inferenceapi.wethinkdigital.solutions/v1",
});
const stream = await client.chat.completions.create({
model: "model-pro",
messages: [{ role: "user", content: "Write a short release note." }],
stream: true,
});
for await (const chunk of stream) {
const delta = chunk.choices[0]?.delta?.content;
if (delta) process.stdout.write(delta);
}data: {"id":"chatcmpl_…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"}}]}
data: {"id":"chatcmpl_…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hello"}}]}
data: {"id":"chatcmpl_…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":24,"completion_tokens":8,"total_tokens":32}}
data: [DONE]List models
Model metadata includes the platform ID, context window, max output tokens, capabilities, and pricing. Use this endpoint as the source of truth for model IDs.
curl https://inferenceapi.wethinkdigital.solutions/v1/models \
-H "Authorization: Bearer sk_live_xxxxxxxx"{
"object": "list",
"data": [
{
"id": "model-pro",
"object": "model",
"owned_by": "platform",
"context_window": 200000,
"max_output_tokens": 8192,
"capabilities": {
"streaming": true,
"tools": true,
"vision": true,
"json_mode": true
}
}
]
}Response fields
A successful non-streaming completion returns a standard chat.completion object. Usage is recorded against your balance per request.
{
"id": "chatcmpl_01J...",
"object": "chat.completion",
"created": 1770000000,
"model": "model-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The CAP theorem states that a distributed data store can..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 118,
"total_tokens": 160
}
}| Field | Type | Description |
|---|---|---|
| id | string | Unique completion identifier. |
| model | string | The platform model ID that served the request. |
| choices[].message.content | string | Generated assistant content. May be empty when a tool call is returned. |
| choices[].finish_reason | string | Why generation stopped: stop, length, tool_calls, or content_filter. |
| usage | object | prompt_tokens, completion_tokens, and total_tokens used for billing. |
Tools & structured output
Tool calling and JSON mode are enabled per model. Check the capabilities object returned by GET /v1/models before depending on them.
{
"capabilities": {
"streaming": true,
"tools": true,
"vision": false,
"json_mode": true
}
}Requests using an unsupported capability return a structured 400 error. Model IDs and capability flags can change when the catalog is updated; resolve them at startup or cache them with a short TTL.