Quickstart: ask a model a question

Send your first message to a model from the command line, and see the units it used.

This quickstart asks a model a question with curl, then reads the answer and its usage with jq.

Before you begin

Set up your environment, so AI_API_KEY and AI_URL are set.

Ask a question

  1. Send a message

    curl -s "$AI_URL/chat/completions" \
      -H "Authorization: Bearer $AI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "openai/gpt-oss-20b",
        "messages": [
          {
            "role": "user",
            "content": "In one sentence, what is Dar es Salaam known for?"
          }
        ]
      }' > answer.json
  2. Read the answer

    jq -r '.choices[0].message.content' answer.json
  3. See what it used

    jq '.usage' answer.json

    prompt_tokens and completion_tokens are the tokens the model read and wrote, and units is the AI units the call used.

What’s next

Last updated