Skip to main content

Chat completions

OpenAI-compatible chat endpoint. Works with any text or vision LLM — platform models and your own user inference instances alike.

POST https://api.ecohash.com/v1/chat/completions

Headers

HeaderValue
AuthorizationBearer eco_YOUR_KEY
Content-Typeapplication/json

Request body

FieldTypeRequiredNotes
modelstringyesModel ID — either a platform model (e.g. meta-llama/Llama-3.1-8B-Instruct) or a user inference instance (<name>:<id> format)
messagesarrayyes{role, content} objects
max_tokensintegernoUpper bound on completion length
temperaturenumberno0–2, default 1.0
top_pnumberno0–1
streamboolnotrue for SSE streaming
stopstring or arraynoStop sequences
presence_penaltynumberno-2 to 2
frequency_penaltynumberno-2 to 2
seedintegernoDeterministic sampling (when supported)
response_formatobjectno{"type": "json_object"} for JSON mode
toolsarraynoFunction-calling tool definitions
tool_choicestring or objectno"auto", "none", or a specific tool

Example request

curl https://api.ecohash.com/v1/chat/completions \
-H "Authorization: Bearer eco_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "meta-llama/Llama-3.1-8B-Instruct",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "What is EcoLink?"}
],
"max_tokens": 200,
"temperature": 0.7
}'

Response body

Standard OpenAI schema:

{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1776391234,
"model": "meta-llama/Llama-3.1-8B-Instruct",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "EcoLink is a GPU cloud platform ..."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 24,
"total_tokens": 42
}
}

Streaming

With "stream": true, the response is a sequence of data: <json>\n\n server-sent events:

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"role":"assistant","content":""},"index":0}]}

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"},"index":0}]}

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"content":" there"},"index":0}]}

data: [DONE]

Vision input

For vision LLMs, images go in the content array as image_url parts:

{
"model": "Qwen/Qwen2.5-VL-7B-Instruct",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
]
}]
}

url can be either a https:// URL or a data URL: data:image/jpeg;base64,<base64-bytes>.

Response headers

HeaderMeaning
x-ecolink-regionRegion that served this request
x-ecolink-request-idUnique ID for this request (include in support requests)

Error responses

See Errors for the full list. Common:

HTTPMeaning
401Bad or missing API key
402Balance insufficient or model not priced
404Unknown model ID
429Rate limited
503No healthy region for this model