Create a chat completion
Send a JSON POST request to https://api.arnict.com/v1/chat/completions with your API key. Include a public model ID and a messages array.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.arnict.com/v1",
apiKey: process.env.ARNICT_API_KEY,
});
const completion = await client.chat.completions.create({
model: "zai/glm-5.3-flash-uncensored",
messages: [{ role: "user", content: "Say hello in one sentence." }],
max_tokens: 256,
});
console.log(completion.choices[0].message.content);Compatibility scope
Request parameters
| Parameter | Type | How to use it |
|---|---|---|
| model | string, required | An available public model ID. |
| messages | array, required | Conversation messages with a role and content. Include previous turns when your application needs conversation context. |
| max_tokens | positive integer | An output limit within the selected model’s published maximum. |
| max_completion_tokens | positive integer | An alternative output-limit field. Use one output-limit field per request. |
| stream | boolean | Use true for streamed events. The default is false. |
| stream_options | object | For streaming, use {"include_usage": true} to request token usage. |
| temperature | number | A sampling setting, where supported by the selected model. |
| top_p | number | A sampling setting, where supported by the selected model. |
| stop | string or array | Stop sequences, where supported by the selected model. |
Output limits vary by model. Leave room for the input and output within the model’s context window. Start with a modest output limit and increase it when your application needs longer responses.
Check optional capabilities
Read the result
| Field | Meaning |
|---|---|
| id | Identifier for the completion. |
| model | The public model ID used for the request. |
| choices | The generated choices. For a standard request, read choices[0].message.content. |
| choices[].finish_reason | Why generation ended. For example, stop indicates completion and length indicates a limit was reached. |
| usage | Token counts, when provided. See Pricing for how token categories affect cost. |
Read X-Request-ID from the HTTP response headers when diagnosing a request. Keep the ID and status code in your application’s operational logs; avoid logging credentials or sensitive content.
- Stream the responseReceive incremental content instead of waiting for a complete JSON response.
- Understand token pricingRead input, cached input and output usage.
