> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yelu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Make your first Yelu AI API request with curl, JavaScript Fetch, Python, or the OpenAI SDK.

This guide sends a non-streaming chat request, reads the assistant message, and shows how to switch to the official OpenAI SDK.

## 1. Create an API key

Sign in to the [Yelu dashboard](https://yelu.ai), create an API key, and copy it immediately. Store it in a password manager or secret manager; do not commit it to source control.

## 2. Set your environment

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export YELU_API_KEY="your_api_key"
```

For persistent local development, use your framework's ignored environment file. In production, inject the value from your hosting platform's secret store.

## 3. Send a request

<CodeGroup>
  ```bash Curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl https://api.yelu.ai/v1/chat/completions \
    -H "Authorization: Bearer $YELU_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-4o-mini",
      "messages": [
        {"role": "system", "content": "Answer clearly and concisely."},
        {"role": "user", "content": "Explain semantic search in two sentences."}
      ]
    }'
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const response = await fetch('https://api.yelu.ai/v1/chat/completions', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.YELU_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'gpt-4o-mini',
      messages: [
        { role: 'system', content: 'Answer clearly and concisely.' },
        { role: 'user', content: 'Explain semantic search in two sentences.' },
      ],
    }),
  });

  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.error?.message ?? `HTTP ${response.status}`);
  }

  const data = await response.json();
  console.log(data.choices[0].message.content);
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import os
  import requests

  response = requests.post(
      "https://api.yelu.ai/v1/chat/completions",
      headers={
          "Authorization": f"Bearer {os.environ['YELU_API_KEY']}",
          "Content-Type": "application/json",
      },
      json={
          "model": "gpt-4o-mini",
          "messages": [
              {"role": "system", "content": "Answer clearly and concisely."},
              {"role": "user", "content": "Explain semantic search in two sentences."},
          ],
      },
      timeout=60,
  )
  response.raise_for_status()
  print(response.json()["choices"][0]["message"]["content"])
  ```
</CodeGroup>

<Tip>
  Model access is account-specific. If the example model is unavailable, call [`GET /v1/models`](/en/api-reference/models) and use any returned `id`.
</Tip>

## 4. Use the OpenAI SDK

Yelu accepts OpenAI-compatible SDK requests. Configure the key and base URL; the rest of your application can use normal SDK methods.

<CodeGroup>
  ```bash Curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl https://api.yelu.ai/v1/models \
    -H "Authorization: Bearer $YELU_API_KEY"
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: process.env.YELU_API_KEY,
    baseURL: 'https://api.yelu.ai/v1',
  });

  const completion = await client.chat.completions.create({
    model: 'gpt-4o-mini',
    messages: [{ role: 'user', content: 'Say hello from Yelu.' }],
  });

  console.log(completion.choices[0].message.content);
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import os
  from openai import OpenAI

  client = OpenAI(
      api_key=os.environ["YELU_API_KEY"],
      base_url="https://api.yelu.ai/v1",
  )

  completion = client.chat.completions.create(
      model="gpt-4o-mini",
      messages=[{"role": "user", "content": "Say hello from Yelu."}],
  )

  print(completion.choices[0].message.content)
  ```
</CodeGroup>

## 5. Verify the result

A successful Chat Completions response includes an `id`, `model`, `choices`, and `usage`. The generated text is at `choices[0].message.content`.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "chatcmpl_01JYELU7GATEWAY",
  "object": "chat.completion",
  "created": 1783900800,
  "model": "gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Semantic search retrieves information by meaning rather than exact keyword matches. It represents text as vectors and finds items that are close in that vector space."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 29,
    "total_tokens": 54
  }
}
```

<CardGroup cols={2}>
  <Card title="Stream tokens" icon="activity" href="/en/guides/streaming">
    Render output as the model generates it.
  </Card>

  <Card title="Call tools" icon="wrench" href="/en/guides/function-calling">
    Connect models to your application functions.
  </Card>
</CardGroup>
