Chat Completions
Send a conversation using the OpenAI Chat format. Check that your model and selected endpoint support the Chat protocol before sending the request.
Before you start
Follow the quickstart to get an API key and select an endpoint that accepts direct HTTP calls. The example reads the Bearer token from ICODEEASY_API_KEY. Replace YOUR_MODEL_ID with a model ID supported by your endpoint.
Request example
Set model to your model ID and put the conversation in messages. Use stream: false to request JSON.
curl -sS https://api.icodeeasy.cc/v1/chat/completions \
-H "Authorization: Bearer $ICODEEASY_API_KEY" \
-H 'Content-Type: application/json' \
--data '{
"model": "YOUR_MODEL_ID",
"messages": [
{
"role": "user",
"content": "Say hello."
}
],
"stream": false
}'
Read the response
Read text from choices[].message.content. The usage object can include prompt_tokens, completion_tokens, and total_tokens. When present, usage.prompt_tokens_details.cached_tokens counts cached input tokens.
{
"choices": [
{
"message": {
"role": "assistant",
"content": "Hello!"
},
"finish_reason": "stop"
}
]
}
Streaming response example
Set stream: true in the request body to receive SSE. In SSE, accumulate delta.content separately for each choices[].index. Record each choice's finish_reason and keep reading for a final usage chunk or [DONE]. An error frame or a disconnect before any completion signal leaves the result failed or incomplete.
data: {"choices":[{"index":0,"delta":{"content":"Hello!"},"finish_reason":null}]}
data: {"choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"choices":[],"usage":{"prompt_tokens":10,"completion_tokens":4,"total_tokens":14}}
data: [DONE]
For endpoints that support streaming usage, request stream_options.include_usage: true. A usage-only chunk may have empty choices.
Related guides
Getting Started
Create an account, obtain an API key, choose an endpoint, and send a first request to confirm that I Code Easy is working.
Model Capability Catalog
Compare public text, image, and video models by normalized request ID, compatible protocols, supported clients, tool use, media capabilities, limits, and review date.
How do I troubleshoot slow connections or failed requests?
Match 401, 403, 429, timeouts, and Gemini path errors before changing hosts. Switch to the jp or sg backup domain only after the network is the problem.