OpenAI compatible
Chat Completions
An OpenAI Chat Completions compatible endpoint for most chat models, with tool calling and SSE streaming.
POST
/v1/chat/completionsKey request parameters
| Parameter | Type | Description |
|---|---|---|
model | string · Required | Model ID from GET /v1/models |
messages | Message[] · Required | Ordered system, user, assistant, or tool messages |
stream | boolean | Whether to return an SSE stream; defaults to false |
temperature | number | Sampling temperature, from 0 to 2 |
max_tokens | integer | Maximum number of generated tokens |
tools | Tool[] | Functions the model can call |
Key response parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Response ID |
choices | Choice[] | Candidate outputs with message and finish_reason |
usage | object | prompt_tokens, completion_tokens, and total_tokens |
model | string | Actual inference model |
X-HashBid-Cost | decimal string | Charge for this call (response header, non-streaming requests only); currency in X-HashBid-Cost-Currency |
Integration examples
Replace the API key and model ID in these examples with your values.
cURL
curl https://hashbidx.ai/v1/chat/completions \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "<MODEL_ID>",
"messages": [{"role": "user", "content": "Hello, HashBid"}],
"max_tokens": 1024
}'Python
from openai import OpenAI
client = OpenAI(
api_key="<YOUR_API_KEY>",
base_url="https://hashbidx.ai/v1",
)
result = client.chat.completions.create(
model="<MODEL_ID>",
messages=[{"role": "user", "content": "Hello, HashBid"}],
)
print(result.choices[0].message.content)Node.js
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "<YOUR_API_KEY>",
baseURL: "https://hashbidx.ai/v1",
});
const result = await client.chat.completions.create({
model: "<MODEL_ID>",
messages: [{ role: "user", content: "Hello, HashBid" }],
});
console.log(result.choices[0].message.content);Go
body, _ := json.Marshal(map[string]any{
"model": "<MODEL_ID>",
"messages": []map[string]any{
{"role": "user", "content": "Hello, HashBid"},
},
})
req, _ := http.NewRequest("POST",
"https://hashbidx.ai/v1/chat/completions", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer <YOUR_API_KEY>")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)Rust
let response = reqwest::Client::new()
.post("https://hashbidx.ai/v1/chat/completions")
.bearer_auth("<YOUR_API_KEY>")
.json(&serde_json::json!({
"model": "<MODEL_ID>",
"messages": [{"role": "user", "content": "Hello, HashBid"}],
}))
.send().await?;
let body: serde_json::Value = response.json().await?;If the response includes X-Request-Id, include it when troubleshooting an issue.