# Quickstart
URL: https://docs.avey.ai/quickstart
Description: 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](https://platform.avey.ai) 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.
```bash noCopy
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.
```bash
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?" }
]
}'
```
```python
# pip install openai
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.avey.ai/llm",
api_key=os.environ["AVEY_API_KEY"],
)
response = client.chat.completions.create(
model="olive",
messages=[
{"role": "user", "content": "What are the red flags for headache in primary care?"}
],
)
print(response.choices[0].message.content)
```
```javascript
// npm install openai
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.avey.ai/llm",
apiKey: process.env.AVEY_API_KEY,
});
const response = await client.chat.completions.create({
model: "olive",
messages: [
{ role: "user", content: "What are the red flags for headache in primary care?" },
],
});
console.log(response.choices[0].message.content);
```
```go
// go get github.com/openai/openai-go/v2
package main
import (
"context"
"fmt"
"os"
"github.com/openai/openai-go/v2"
"github.com/openai/openai-go/v2/option"
)
func main() {
client := openai.NewClient(
option.WithBaseURL("https://api.avey.ai/llm"),
option.WithAPIKey(os.Getenv("AVEY_API_KEY")),
)
resp, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
Model: "olive",
Messages: []openai.ChatCompletionMessageParamUnion{
openai.UserMessage("What are the red flags for headache in primary care?"),
},
})
if err != nil {
panic(err)
}
fmt.Println(resp.Choices[0].Message.Content)
}
```
## Read the response
The response is an OpenAI chat completion, shortened here. Olive adds one field.
```json noCopy
{
"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](/capabilities/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](/concepts/models#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](/concepts/models#token-budget).
* **Any other status.** See [Errors](/concepts/errors) for what each status
means and what to do.
## Next steps