# Tasks (https://inference.net/docs/api/tasks)

A task is one job your application asks a model to do, such as "summarize this document", "classify this ticket", or "extract these fields". You give each task a name, and Inference.net groups every request with that name together.

Tasks group requests by purpose, not by model or prompt. You can change the model or rewrite the prompt for a task, and its history stays in one place.

## Why use tasks

When your application has more than one AI feature, tasks let you:

- See requests, cost, and success rate for each feature separately.
- Compare the models each feature uses.
- Change the model or prompt for one feature without mixing its numbers with the others.

## Create a task

You create a task by sending a request with the `x-inference-task-id` header. You do not need to set it up first. The task appears in the dashboard when the first request with that header arrives.

Use a short, descriptive name in lowercase with hyphens, such as `document-summary`, `ticket-classifier`, or `extract-product-data`. Every request that uses the same name belongs to the same task.

### Set the task on each request

Use this when one client sends requests for more than one task.

<CodeTabs>

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.inference.net/v1",
  apiKey: process.env.INFERENCE_API_KEY,
});

const response = await client.chat.completions.create(
  {
    model: "glm-5.2",
    messages: [{ role: "user", content: "Summarize this document..." }],
  },
  {
    headers: { "x-inference-task-id": "document-summary" },
  },
);
```

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.inference.net/v1",
    api_key=os.environ["INFERENCE_API_KEY"],
)

response = client.chat.completions.create(
    model="glm-5.2",
    messages=[{"role": "user", "content": "Summarize this document..."}],
    extra_headers={"x-inference-task-id": "document-summary"},
)
```

```bash
curl https://api.inference.net/v1/chat/completions \
  -H "Authorization: Bearer $INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "x-inference-task-id: document-summary" \
  -d '{
    "model": "glm-5.2",
    "messages": [{"role": "user", "content": "Summarize this document..."}]
  }'
```

</CodeTabs>

### Set the task for a whole client

Use this when a client only sends requests for one task. Put the header in the client's default headers, and every request from that client belongs to the task.

<CodeTabs>

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.inference.net/v1",
  apiKey: process.env.INFERENCE_API_KEY,
  defaultHeaders: { "x-inference-task-id": "document-summary" },
});
```

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.inference.net/v1",
    api_key=os.environ["INFERENCE_API_KEY"],
    default_headers={"x-inference-task-id": "document-summary"},
)
```

</CodeTabs>

<Callout tone="info">

The header works the same way when you proxy requests through the Inference.net Gateway with your own provider API key. See the [headers reference](/docs/api/quickstart/#headers-reference).

</Callout>

## The default task

Requests without an `x-inference-task-id` header go into the **default** task. A header set to `default` does the same. These requests are still recorded, but they all share one group. Add task names to see each feature on its own.

## See your tasks

Open [Usage](/dashboard/usage/) in the dashboard and select **Tasks**. Each task shows its requests, cost, success rate, and the models it used for the selected time range.

Select a task to see its usage over time. To hide a task you no longer use, archive it from the task list. You can unarchive it later.