Skip to main content
POST
/
chat
/
completions
Create Chat Completion
curl --request POST \
  --url https://api.electronhub.ai/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "system",
      "content": "<string>",
      "reasoning": "<string>",
      "reasoning_content": "<string>",
      "name": "<string>",
      "tool_calls": [
        {
          "id": "<string>",
          "type": "function",
          "function": {
            "name": "<string>",
            "arguments": "<string>"
          }
        }
      ]
    }
  ],
  "stream": false,
  "max_tokens": 123,
  "temperature": 1,
  "top_p": 1,
  "top_k": 123,
  "frequency_penalty": 0,
  "presence_penalty": 0,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "<string>",
        "description": "<string>",
        "parameters": {}
      }
    }
  ],
  "tool_choice": "none",
  "web_search": false,
  "reasoning_effort": "none",
  "reasoning": {
    "effort": "none",
    "exclude": true,
    "delta_field": "reasoning"
  },
  "reasoning_delta_field": "reasoning",
  "reasoning_content_compat": true
}
'
{
  "id": "<string>",
  "object": "chat.completion",
  "created": 123,
  "model": "<string>",
  "choices": [
    {
      "index": 123,
      "message": {
        "role": "system",
        "content": "<string>",
        "reasoning": "<string>",
        "reasoning_content": "<string>",
        "name": "<string>",
        "tool_calls": [
          {
            "id": "<string>",
            "type": "function",
            "function": {
              "name": "<string>",
              "arguments": "<string>"
            }
          }
        ]
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.electronhub.ai/llms.txt

Use this file to discover all available pages before exploring further.

Create conversational AI responses using our chat completions endpoint.

Create Chat Completion

POST /chat/completions Generate responses for conversational AI applications.

Request Body

model
string
required
Model to use for completion (e.g., gpt-4o, gpt-5.1, claude-sonnet-4-6, deepseek-r1). Append :reasoning-exclude to disable reasoning output for a single request.
messages
array
required
Array of message objects forming the conversation.
max_tokens
integer
Maximum number of tokens to generate. Reasoning tokens are billed as output tokens and counted against this limit.
temperature
number
Sampling temperature between 0 and 2.
stream
boolean
Enable streaming responses (SSE).
reasoning_effort
string
Controls reasoning depth on supported models. One of none, minimal, low, medium, high, xhigh. Silently ignored for models that don’t support reasoning_effort.
reasoning
object
Reasoning configuration object. Supports:
  • reasoning.effort — same enum as reasoning_effort.
  • reasoning.exclude (boolean) — strip reasoning from the response entirely.
  • reasoning.delta_field"reasoning" or "reasoning_content"; overrides the streaming/non-streaming field name regardless of which endpoint variant was hit.
reasoning_delta_field
string
Shorthand for reasoning.delta_field. Accepts "reasoning" or "reasoning_content".
reasoning_content_compat
boolean
Shorthand: set to true to force the legacy reasoning_content field, equivalent to reasoning.delta_field = "reasoning_content".

Endpoint Variants (Reasoning Output)

Some models emit a separate reasoning / thinking stream in addition to the final answer. Three base paths control how that stream is surfaced — all of them accept the same request shape and model names.
Base pathBehaviorUse when
POST /v1/chat/completionsReasoning and answer are returned as separate fields (reasoning + content). Default.Most OpenAI-compatible clients.
POST /v1legacy/chat/completionsSame as /v1/, but reasoning uses the legacy field name reasoning_content.Clients that only parse reasoning_content (e.g. older DeepSeek SDKs).
POST /v1thinking/chat/completionsReasoning and answer are merged into the normal content stream, wrapped in <think>...</think> tags.Clients that ignore reasoning fields but should still display thoughts inline.
Per-request overrides (reasoning.delta_field, reasoning_delta_field, reasoning_content_compat) take precedence over the endpoint default. If a model does not emit reasoning, these fields are simply absent from the response.

Streaming output shape

When reasoning is delivered as a separate field, deltas are interleaved — reasoning chunks come first, followed by content chunks:
data: {"id":"chatcmpl-...","choices":[{"index":0,"delta":{"reasoning":"Let me think..."},"finish_reason":null}], ...}

data: {"id":"chatcmpl-...","choices":[{"index":0,"delta":{"content":"The answer is 4."},"finish_reason":null}], ...}

data: [DONE]
Against /v1legacy/chat/completions the same deltas use delta.reasoning_content instead of delta.reasoning. Against /v1thinking/chat/completions everything appears in delta.content:
data: {"choices":[{"delta":{"content":"<think>Let me think...</think>The answer is 4."}}]}

Non-streaming output shape

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "The answer is 4.",
      "reasoning": "Let me think..."
    },
    "finish_reason": "stop"
  }],
  "usage": { "...": "..." }
}
reasoning becomes reasoning_content on /v1legacy/. On /v1thinking/, the reasoning stays embedded inside content ("<think>...</think>The answer...") and no separate field is emitted.

Disabling Reasoning Output

Reasoning can be hidden in three equivalent ways — the model still pays the cost for reasoning compute, but the tokens are stripped from the response:
  1. Request body: { "reasoning": { "exclude": true } }
  2. Model suffix: "model": "deepseek-r1:reasoning-exclude"
  3. Request body: { "reasoning_effort": "none" } (only honored on OpenAI-shaped models — safely ignored elsewhere for API parity).
When excluded, neither the reasoning field nor <think> tags appear in the response, regardless of which endpoint variant was hit.

Example

import requests

# Default: reasoning + content in separate fields
response = requests.post(
    'https://api.electronhub.ai/v1/chat/completions',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'model': 'deepseek-r1',
        'messages': [{'role': 'user', 'content': "What's 2 + 2?"}],
        'reasoning_effort': 'medium'
    }
)
data = response.json()
print(data['choices'][0]['message']['reasoning'])  # thinking text
print(data['choices'][0]['message']['content'])    # answer

Streaming

Enable real-time responses with streaming:
curl https://api.electronhub.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-3.5-turbo",
    "messages": [
      {"role": "user", "content": "Tell me a story"}
    ],
    "stream": true
  }'

Function Calling

Use function calling for tool integration:
curl https://api.electronhub.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "messages": [
      {"role": "user", "content": "What is the weather like in Boston?"}
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_current_weather",
          "description": "Get the current weather in a given location",
          "parameters": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "description": "The city and state, e.g. San Francisco, CA"
              },
              "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
            },
            "required": ["location"]
          }
        }
      }
    ],
    "tool_choice": "auto"
  }'

Authorizations

Authorization
string
header
required

Enter your API key (starts with 'ek-')

Body

application/json
model
string
required

Model to use for completion

Example:

"gpt-4o"

messages
object[]
required

List of messages

stream
boolean
default:false

Enable streaming

max_tokens
integer

Maximum tokens to generate

temperature
number
default:1

Sampling temperature

Required range: 0 <= x <= 2
top_p
number
default:1

Nucleus sampling

Required range: 0 <= x <= 1
top_k
integer

Top-k sampling

frequency_penalty
number
default:0
Required range: -2 <= x <= 2
presence_penalty
number
default:0
Required range: -2 <= x <= 2
tools
object[]

List of tools

tool_choice
Available options:
none,
auto

Enable web search

thinking
object
reasoning_effort
enum<string>

Reasoning effort level. Silently ignored for models that do not support reasoning_effort, so clients can send a single shared request across providers.

Available options:
none,
minimal,
low,
medium,
high,
xhigh
reasoning
object

Reasoning configuration. Per-request override for reasoning output behavior.

reasoning_delta_field
enum<string>

Shorthand for reasoning.delta_field.

Available options:
reasoning,
reasoning_content
reasoning_content_compat
boolean

Shorthand: set to true to force the legacy reasoning_content field, equivalent to reasoning.delta_field = "reasoning_content".

Response

200 - application/json

Success

id
string
required
object
string
required
Example:

"chat.completion"

created
integer
required
model
string
required
choices
object[]
required
usage
object