Quickstart

Create an API key, send your first request to Olive, and read the response.

Create an API key

Sign in to the Avey API platform and create a key. The full key is shown once, when you create it. Store it in an environment variable, and keep it out of source control.

export AVEY_API_KEY="avey_sk1_..."

Make a request

Send the key as a bearer token in the Authorization header. The OpenAI SDKs send that header already, so set the key as api_key and nothing else.

curl https://api.avey.ai/llm/chat/completions \
  -H "Authorization: Bearer $AVEY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "olive",
    "messages": [
      { "role": "user", "content": "What are the red flags for headache in primary care?" }
    ]
  }'

Read the response

The response is an OpenAI chat completion, shortened here. Olive adds one field.

{
  "id": "chatcmpl-8Qp0vJnZ2xTfKq3mBd1sYw",
  "object": "chat.completion",
  "created": 1753660800,
  "model": "olive",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "reasoning_content": "The question is asking which features of a headache presentation raise the probability of a secondary cause...",
        "content": "Screen for these red flags in any patient presenting with headache:\n\n1. **Thunderclap onset**: maximal intensity within a minute..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 412,
    "total_tokens": 430
  }
}
  • message.reasoning_content holds Olive's reasoning, kept apart from the answer in content. An SDK that does not know the field may drop it. See Reasoning.
  • finish_reason is stop when Olive finished. It is length when the response hit the max_tokens budget, and the answer may be cut short. See Token budget.
  • usage holds the token counts. On a stream, it arrives on the final chunk.

If the first request fails

  • Every request returns 401. When you leave api_key unset, an OpenAI SDK sends a key it finds in your environment instead. That key can belong to another project, and Avey answers 401. Pass your Avey key explicitly.
  • content is empty and finish_reason is length. Reasoning used the whole max_tokens budget. Raise max_tokens, or leave it unset. See Token budget.
  • Any other status. See Errors for what each status means and what to do.

Next steps

Last updated