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

# Quickstart

> Send your first FreeModel chat completion.

This guide sends a chat completion through the OpenAI-compatible API.

## Before you begin

Create an API key in the FreeModel Console under **API Keys**. Add prepaid balance under **Billing** before sending requests.

## Send a chat completion

Set your key in the current shell, then run the request.

```bash theme={null}
export FREEMODEL_API_KEY="sk-xxxx"

curl https://api.freemodel.app/v1/chat/completions \
  -H "Authorization: Bearer $FREEMODEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [
      {
        "role": "user",
        "content": "Write a one-sentence welcome to FreeModel."
      }
    ]
  }'
```

The response contains the generated text at `choices[0].message.content`.

## Use an OpenAI SDK

FreeModel works with the official OpenAI SDKs. Set `base_url` to the FreeModel API base URL.

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="sk-xxxx",
      base_url="https://api.freemodel.app/v1",
  )

  completion = client.chat.completions.create(
      model="gpt-5.4-mini",
      messages=[
          {"role": "user", "content": "Write a one-sentence welcome to FreeModel."}
      ],
  )

  print(completion.choices[0].message.content)
  ```

  ```javascript Node.js theme={null}
  const OpenAI = require("openai");

  async function main() {
    const client = new OpenAI({
      apiKey: "sk-xxxx",
      baseURL: "https://api.freemodel.app/v1",
    });

    const completion = await client.chat.completions.create({
      model: "gpt-5.4-mini",
      messages: [
        { role: "user", content: "Write a one-sentence welcome to FreeModel." },
      ],
    });

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

  main();
  ```
</CodeGroup>

Install the matching SDK before running the example:

<CodeGroup>
  ```bash Python theme={null}
  pip install openai
  ```

  ```bash Node.js theme={null}
  npm install openai
  ```
</CodeGroup>

## Stream the response

Set `stream` to `true` to receive server-sent events as text is generated.

```bash theme={null}
curl -N https://api.freemodel.app/v1/chat/completions \
  -H "Authorization: Bearer sk-xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "stream": true,
    "messages": [
      {
        "role": "user",
        "content": "Count from one to three."
      }
    ]
  }'
```

See [Chat completions](/api-reference/chat-completions#stream-a-response) for the streaming event format.

## Generate media

Keep your first integration chat-first. When you need generated media, use [Images](/api-reference/images) to create and decode a synchronous image response, or use [Video generation](/api-reference/video-generation) to submit, poll, and download an asynchronous video.
