Browse documentation→
Docs/OpenAI-compatible API
Compatibility guide

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

POSThttps://inferenceapi.wethinkdigital.solutions/v1/chat/completions

Create a chat completion. Supports streaming with server-sent events.

GEThttps://inferenceapi.wethinkdigital.solutions/v1/models

List the active model catalog available to your account.

GEThttps://inferenceapi.wethinkdigital.solutions/v1/models/{model}

Retrieve a single model, including limits and capabilities.

Use the base URL override

For the OpenAI SDK, set 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

FieldTypeDescription
modelstringRequired. A platform model ID from the active catalog.
messagesarrayRequired. Ordered conversation turns with role and content. System, user, and assistant roles are supported.
max_tokensintegerOptional. Upper bound on generated output tokens. Defaults and limits depend on the model.
temperaturenumberOptional. Sampling temperature. Supported range is model-dependent.
streambooleanOptional. When true, the response is an SSE stream of chat.completion.chunk objects.
toolsarrayOptional. 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);
}
sse-stream
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"
models-response.json
{
  "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.

completion-response.json
{
  "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
  }
}
FieldTypeDescription
idstringUnique completion identifier.
modelstringThe platform model ID that served the request.
choices[].message.contentstringGenerated assistant content. May be empty when a tool call is returned.
choices[].finish_reasonstringWhy generation stopped: stop, length, tool_calls, or content_filter.
usageobjectprompt_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.

capability-check
{
  "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.