Chat completions
A chat completion is simply "send a message to an AI and get an answer back". client.chat.complete() sends one request and gives you the whole answer when it is ready.
Your first question
const response = await client.chat.complete({
model: 'auto',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Explain quantum computing in one sentence.' },
],
});
console.log(response.choices[0].message.content);
What the pieces mean:
model: 'auto'lets Artemis pick the best model.messagesis the conversation. Each message has a role:system: instructions for how the AI should behave.user: what the person says.assistant: what the AI said before (used for follow-ups).
response.choices[0].message.contentis the answer text.
Parameters
| Parameter | Type | Required | What it means |
|---|---|---|---|
model | string | Yes | An Artemis option (artemis-cost, artemis-balanced, artemis-quality) for automatic selection by Artemis at that preset. auto is artemis-balanced (auto-artemis-task, auto-v2 and nuroute/artemis mean the same). Or a specific model identifier, e.g. gpt-4o, claude-sonnet-4-6 |
messages | ChatMessage[] | Yes | The conversation so far |
temperature | number | No | How adventurous the answer is, from 0 (careful) to 2 (wild) |
maxTokens | number | No | The longest answer you allow. Over a project policy's max_tokens limit, the request is refused with 400. If you leave it out, the project's limit applies |
provider | string | No | Force a specific provider, e.g. openai, anthropic. No router runs: with model: 'auto' the provider serves the first model it lists |
router | RouterChoice ('artemis' | 'v2') | No | Not needed. Artemis decides every model: 'auto' request, so both values change nothing. It is sent as the x-nuroute-router header. Any other value is rejected with a NuRouteError whose status is 400 |
With model: 'auto', Artemis picks the model and the provider. If it cannot decide, the fallback router does, and the request log says why (Which router decided). A request that names a model uses no router.
Choosing a provider yourself
Normally NuRoute picks the provider by your routing settings. You can pin a request to one provider:
const response = await client.chat.complete({
model: 'claude-haiku-4-5-20251001',
messages: [{ role: 'user', content: 'Hello!' }],
provider: 'anthropic',
});
Back-and-forth conversations
The AI does not remember earlier messages by itself. To hold a conversation, send the whole history each time, and add each new reply to it:
const messages: ChatMessage[] = [
{ role: 'system', content: 'You are a helpful assistant.' },
];
async function chat(userMessage: string) {
messages.push({ role: 'user', content: userMessage });
const response = await client.chat.complete({ model: 'auto', messages });
const reply = response.choices[0].message;
messages.push(reply);
return reply.content;
}
console.log(await chat('What is 2 + 2?'));
console.log(await chat('And multiply that by 10?'));
What the answer looks like
The SDK gives you the answer body only. The gateway's X-Router-* headers are not exposed. To see which router decided, use the request log (Which router decided).
{
id: 'chatcmpl-…',
object: 'chat.completion',
model: 'gpt-4o-mini',
choices: [
{
index: 0,
message: { role: 'assistant', content: '…' },
finish_reason: 'stop',
},
],
usage: {
prompt_tokens: 10,
completion_tokens: 42,
total_tokens: 52,
},
}
| Field | Plain meaning |
|---|---|
model | The model that really answered |
choices[0].message.content | The answer text |
finish_reason | Why the answer ended. stop means it finished naturally |
usage | How many tokens were used: in your prompt, in the answer, and in total |