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

# How to Create a Task

Task are automatically created when you send requests with a `x-inference-task-id` header. The task appears in the dashboard as soon as the first tagged request comes through.

## Set the task header

Add `x-inference-task-id` to your request. The value is whatever name makes sense for the objective — `document-summary`, `ticket-classifier`, `extract-product-data`, etc.

You can set the task per request, or put it in `defaultHeaders` on the client if all calls from that client belong to the same task.

**Per request** (use when one client serves multiple tasks):

<CodeGroup>
  <Metadata text="observe/create-task-header[series=create-task]" />

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

  <Metadata text="observe/create-task-header[series=create-task]" />

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

  <Metadata text="observe/create-task-header" />

  ```bash cURL theme={"system"}
  curl https://api.inference.net/v1/chat/completions \
    -H "Authorization: Bearer $INFERENCE_API_KEY" \
    -H "x-inference-provider-api-key: $OPENAI_API_KEY" \
    -H "Content-Type: application/json" \
    -H "x-inference-provider: openai" \
    -H "x-inference-task-id: document-summary" \
    -d '{
      "model": "gpt-4.1",
      "messages": [{"role": "user", "content": "Summarize this document..."}]
    }'
  ```
</CodeGroup>

**In default headers** (use when a client is dedicated to one task):

<CodeGroup>
  <Metadata text="observe/create-task-default-header[series=create-task-default]" />

  ```typescript TypeScript theme={"system"}
  import OpenAI from "openai";

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

  <Metadata text="observe/create-task-default-header[series=create-task-default]" />

  ```python Python theme={"system"}
  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-provider-api-key": os.environ["OPENAI_API_KEY"],
          "x-inference-provider": "openai",
          "x-inference-task-id": "document-summary",
          "x-inference-environment": "production",
      },
  )
  ```
</CodeGroup>

## The default task

If you don't set `x-inference-task-id`, the request is grouped under the **default** task. Your traffic is still captured, but it's all in one bucket. Once you start tagging, you can break down metrics, run evals, and build datasets per task.

## Assign task IDs automatically

Use **[Install with AI](/integrations/install-with-ai)** if you want the CLI to add task IDs for you. It runs `inf instrument`, scans your codebase, and names each call site based on what the prompt is doing — for example, `document-summary` or `ticket-classification`. These are starting points; you can rename them by editing the `x-inference-task-id` header value in the generated code.
