> For the complete documentation index, see [llms.txt](https://guides.ia.numerique.gouv.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guides.ia.numerique.gouv.fr/albert-api/prise-en-main/quickstart.md).

# Démarrage rapide

Pour envoyer des requêtes à Albert API vous devez posséder créer une clef d'API depuis l'interface [Playground](https://albert.playground.etalab.gouv.fr/) d'Albert API.

{% hint style="info" %}
Une clef d'API est un identifiant de connexion (*Bearer token*) permettant de vous authentifier lors de vos appels API. Elle commence par `sk-eyJhbG...`.
{% endhint %}

{% stepper %}
{% step %}

### Se connecter au playground

Rendez vous sur [https://albert.playground.etalab.gouv.fr](https://albert.playground.etalab.gouv.fr/) et connectez vous avec Proconnect ([en savoir plus](https://www.proconnect.gouv.fr/)).

Si vous êtes redirigez sur une page vous indiquant que votre accès est refusé, merci de consulter [la section de la FAQ dédiée](/albert-api/ressources/faq.md#pourquoi-mon-compte-nest-pas-autorise).
{% endstep %}

{% step %}

### Créer une clef d'API

Une fois connectez à l'interface Playground, rendez-vous sur la page [*API Keys*](https://albert.playground.etalab.gouv.fr/keys). Sur cette page créer vous une clef en lui attribuant un nom. Vous pouvez configurer la durée d'expiration de votre clef jusqu'à un an.

{% hint style="info" %}
Après création, la clé est affichée **une seule fois**. Copiez-la immédiatement et conservez-la dans un gestionnaire de secrets (ou variable d’environnement), car **vous ne pourrez pas l'afficher** ensuite.

Pour en savoir plus sur les clefs d'API, consultez la documentation dédiée [ici](/albert-api/compte-and-usage/api-keys.md).
{% endhint %}
{% endstep %}

{% step %}

### Appeler un modèle

Pour cette première requête nous allons appelez le modèle `openweight-small`. Ouvrez un terminal et exécutez le code ci-dessous.

{% hint style="info" %}
Remplacez la valeur `$ALBERT_API_KEY` par la valeur de votre clef API.
{% endhint %}

{% tabs %}
{% tab title="Bash" icon="square-terminal" %}

```bash
curl -x POST "https://albert.api.etalab.gouv.fr/v1/chat/completions" \
  -H "Authorization: Bearer $ALBERT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "REMPLACER_PAR_ID_MODELE",
    "messages": [
      {"role": "system", "content": "Tu réponds en français, de façon concise."},
      {"role": "user", "content": "Explique ce qu’est une API compatible OpenAI en deux phrases."}
    ]
  }'

```

{% endtab %}

{% tab title="Python" icon="python" %}

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://albert.api.etalab.gouv.fr/v1",
    api_key=os.environ["ALBERT_API_KEY"],
)

r = client.chat.completions.create(
    model="REMPLACER_PAR_ID_MODELE",
    messages=[
        {"role": "system", "content": "Tu réponds en français, de façon concise."},
        {"role": "user", "content": "Explique ce qu’est une API compatible OpenAI en deux phrases."},
    ],
)
print(r.choices[0].message.content)
```

{% endtab %}

{% tab title="JavaScript" icon="js" %}

```javascript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://albert.api.etalab.gouv.fr/v1",
  apiKey: process.env.ALBERT_API_KEY,
});

const r = await client.chat.completions.create({
  model: "REMPLACER_PAR_ID_MODELE",
  messages: [
    { role: "system", content: "Tu réponds en français, de façon concise." },
    { role: "user", content: "Explique ce qu’est une API compatible OpenAI en deux phrases." }
  ],
});

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

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### Explorer les fonctionnalités et les modèles disponibles

* [Consulter les endpoints disponibles](/albert-api/api-reference/liste-des-endpoint.md)
* [Consulter les modèles disponibles](/albert-api/modeles/available-models.md)
* [Consulter nos guides thématiques](/albert-api/guides/chat-completions.md)
  {% endstep %}
  {% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://guides.ia.numerique.gouv.fr/albert-api/prise-en-main/quickstart.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
