POST /v1/chat/completions
curl --request POST \
--url https://api.geekhub.mx/v1/chat/completions \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"role": {},
"content": "<string>",
"name": "<string>"
}
],
"temperature": 123,
"top_p": 123,
"max_tokens": 123,
"stream": true,
"stop": [
"<string>"
]
}
'import requests
url = "https://api.geekhub.mx/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [
{
"role": {},
"content": "<string>",
"name": "<string>"
}
],
"temperature": 123,
"top_p": 123,
"max_tokens": 123,
"stream": True,
"stop": ["<string>"]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{role: {}, content: '<string>', name: '<string>'}],
temperature: 123,
top_p: 123,
max_tokens: 123,
stream: true,
stop: ['<string>']
})
};
fetch('https://api.geekhub.mx/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.geekhub.mx/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'messages' => [
[
'role' => [
],
'content' => '<string>',
'name' => '<string>'
]
],
'temperature' => 123,
'top_p' => 123,
'max_tokens' => 123,
'stream' => true,
'stop' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.geekhub.mx/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"role\": {},\n \"content\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"temperature\": 123,\n \"top_p\": 123,\n \"max_tokens\": 123,\n \"stream\": true,\n \"stop\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.geekhub.mx/v1/chat/completions")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"role\": {},\n \"content\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"temperature\": 123,\n \"top_p\": 123,\n \"max_tokens\": 123,\n \"stream\": true,\n \"stop\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.geekhub.mx/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"role\": {},\n \"content\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"temperature\": 123,\n \"top_p\": 123,\n \"max_tokens\": 123,\n \"stream\": true,\n \"stop\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message.role": "<string>",
"message.content": "<string>",
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}API Reference
POST /v1/chat/completions
Chat response generation with any model
POST
/
v1
/
chat
/
completions
POST /v1/chat/completions
curl --request POST \
--url https://api.geekhub.mx/v1/chat/completions \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"role": {},
"content": "<string>",
"name": "<string>"
}
],
"temperature": 123,
"top_p": 123,
"max_tokens": 123,
"stream": true,
"stop": [
"<string>"
]
}
'import requests
url = "https://api.geekhub.mx/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [
{
"role": {},
"content": "<string>",
"name": "<string>"
}
],
"temperature": 123,
"top_p": 123,
"max_tokens": 123,
"stream": True,
"stop": ["<string>"]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{role: {}, content: '<string>', name: '<string>'}],
temperature: 123,
top_p: 123,
max_tokens: 123,
stream: true,
stop: ['<string>']
})
};
fetch('https://api.geekhub.mx/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.geekhub.mx/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'messages' => [
[
'role' => [
],
'content' => '<string>',
'name' => '<string>'
]
],
'temperature' => 123,
'top_p' => 123,
'max_tokens' => 123,
'stream' => true,
'stop' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.geekhub.mx/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"role\": {},\n \"content\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"temperature\": 123,\n \"top_p\": 123,\n \"max_tokens\": 123,\n \"stream\": true,\n \"stop\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.geekhub.mx/v1/chat/completions")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"role\": {},\n \"content\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"temperature\": 123,\n \"top_p\": 123,\n \"max_tokens\": 123,\n \"stream\": true,\n \"stop\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.geekhub.mx/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"role\": {},\n \"content\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"temperature\": 123,\n \"top_p\": 123,\n \"max_tokens\": 123,\n \"stream\": true,\n \"stop\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message.role": "<string>",
"message.content": "<string>",
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}Request body
string
required
The namespaced model ID, e.g.
anthropic/claude-sonnet-4-6. See Chat models.array
required
number
default:"varies by model"
Between 0 and 2. Higher = more creative, lower = more deterministic.
number
Between 0 and 1. Nucleus sampling. Alternative to
temperature.integer
Maximum tokens to generate. Default varies by model.
boolean
default:"false"
If
true, responds with Server-Sent Events. See Streaming section below.string | string[]
Sequences that end generation.
Response (non-streaming)
string
Your
request_id (format req_<24hex>). Useful for tracing.string
Always
"chat.completion".integer
Unix timestamp.
string
The namespaced model id (e.g.
anthropic/claude-sonnet-4-6).array
Streaming
For real-time responses, send"stream": true. You’ll receive Server-Sent Events:
data: {"id":"req_xxx","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"req_xxx","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"req_xxx","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" world"},"finish_reason":null}]}
data: {"id":"req_xxx","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]
data: is a JSON with a delta.content that is the next text fragment (can be a word, a syllable, or even a single character).
TypeScript parser
const res = await fetch("https://api.geekhub.mx/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.GEEKHUB_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "anthropic/claude-haiku-4-5",
messages: [{ role: "user", content: "Count to 5" }],
stream: true,
}),
});
const reader = res.body!.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (true) {
const { value, done } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
let nl: number;
while ((nl = buffer.indexOf("\n\n")) !== -1) {
const block = buffer.slice(0, nl);
buffer = buffer.slice(nl + 2);
const data = block.split("\n").find(l => l.startsWith("data:"))?.slice(5).trim();
if (!data || data === "[DONE]") continue;
const chunk = JSON.parse(data);
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
}
Examples per provider
response = client.chat.completions.create(
model="anthropic/claude-sonnet-4-6",
messages=[
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Capital of Mexico?"}
],
max_tokens=200,
)
response = client.chat.completions.create(
model="openai/gpt-5",
messages=[{"role": "user", "content": "Explain QPS in one line"}],
)
response = client.chat.completions.create(
model="google/gemini-2.5-pro",
messages=[{"role": "user", "content": "Hi"}],
temperature=0.5,
)
response = client.chat.completions.create(
model="deepseek/deepseek-v4-pro",
messages=[{"role": "user", "content": "Solve: 23 * 17 step by step"}],
)
Common errors
See Errors for the full catalog. The most frequent in chat:400 invalid_request_error— malformed body (Zod tells you the field inmessage)402 insufficient_balance— no balance404 model_not_found— invalid model id (probably missing namespace)502 provider_unavailable— provider bounced (sometimes it’s a rejected prompt)
⌘I