Skip to main content

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, as a Python dict, when it is ready.

Your first question​

response = client.chat.complete(
model="auto",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in one sentence."},
],
)

print(response["choices"][0]["message"]["content"])

What the pieces mean:

  • model="auto" lets Artemis pick the best model.
  • messages is 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"]["content"] is the answer text.

Parameters​

ParameterTypeRequiredWhat it means
modelstrYesAn 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
messageslist[ChatMessage]YesThe conversation so far
temperaturefloat | NoneNoHow adventurous the answer is, from 0 (careful) to 2 (wild)
max_tokensint | NoneNoThe 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
providerstr | NoneNoForce a specific provider, e.g. anthropic. No router runs: with model="auto" the provider serves the first model it lists
routerRouterChoice | None ("artemis" or "v2")NoNot needed. Artemis decides every model="auto" request, so both values change nothing. It is sent as the x-nuroute-router header. Any other value raises NuRouteError with status 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). The SDK returns the response body only, not the gateway's X-Router-* headers. A request that names a model uses no router.

Choosing a provider yourself​

response = 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:

messages = [{"role": "system", "content": "You are a helpful assistant."}]

def chat(user_message: str) -> str:
messages.append({"role": "user", "content": user_message})
response = client.chat.complete(model="auto", messages=messages)
reply = response["choices"][0]["message"]
messages.append(reply)
return reply["content"]

print(chat("What is 2 + 2?"))
print(chat("And multiply that by 10?"))