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

# First API Call

> Create your first generation task, poll its status, and retrieve the generated asset.

## 1. Get an API key

Create an API key in the [Dashboard](https://linkmodel.ai/en/dashboard). Use it as a bearer token:

```bash theme={null}
Authorization: Bearer <YOUR_API_KEY>
```

For local scripts, store it in an environment variable:

```bash theme={null}
export LINKMODEL_API_KEY="<YOUR_API_KEY>"
```

## 2. Choose an endpoint

| Use case                      | Endpoint                      |
| ----------------------------- | ----------------------------- |
| Generate or edit images       | `POST /image-generation`      |
| Generate videos               | `POST /video-generation`      |
| Poll image tasks              | `GET /query/image-generation` |
| Poll video tasks              | `GET /query/video-generation` |
| OpenAI-compatible chat        | `POST /chat/completions`      |
| Anthropic-compatible messages | `POST /messages`              |

## 3. Create a task

This example creates a video task:

```bash theme={null}
curl --request POST \
  --url https://api.linkmodel.ai/api/v1/video-generation \
  --header "Authorization: Bearer $LINKMODEL_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "sora-2",
    "prompt": "A golden retriever catching a frisbee in slow motion"
  }'
```

The response includes a `task_id`:

```json theme={null}
{
  "code": 0,
  "data": {
    "task_id": "aurora_abc123",
    "status": "processing"
  },
  "msg": "success",
  "request_id": "250b66dd-e1fb-4bb6-b5f6-c668efadc35d"
}
```

## 4. Poll the task

Use the `task_id` with the matching query endpoint:

```bash theme={null}
curl --request GET \
  --url "https://api.linkmodel.ai/api/v1/query/video-generation?task_id=aurora_abc123" \
  --header "Authorization: Bearer $LINKMODEL_API_KEY"
```

Stop polling when `status` is `Success`, `Failed`, or `Cancelled`. When video generation succeeds, `file_url` contains the generated video URL. For image tasks, `output_images` contains generated image URLs.

## 5. Check usage and cost

The create response includes pricing information when available. For model-level pricing and parameters, open the model page in the API Reference or browse the [model catalog](https://linkmodel.ai/en/models).

## Next

Use [Models](/models) to pick the best model family, or open the API Reference for exact request schemas.
