> For the complete documentation index, see [llms.txt](https://docs.testvibe.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.testvibe.com/testvibe-api/api-reference/generation/generate_feature.md).

# generate\_feature

Dispatch AI test generation for a feature. Returns immediately with a `requestId`; the pipeline runs in a cloud sandbox for several minutes.

{% hint style="warning" %}
Generation **consumes account credits**. One generation per feature at a time — a second dispatch while one is in flight returns `409 conflict`.
{% endhint %}

## Request

```
POST /api/v1/ops/projects/{project}/features/{feature}/generate
```

| Parameter | In   | Type   | Required | Description                                                        |
| --------- | ---- | ------ | -------- | ------------------------------------------------------------------ |
| `project` | path | string | yes      | The project's public id.                                           |
| `feature` | path | string | yes      | Feature id or name.                                                |
| `siteUrl` | body | string | no       | Test site URL override (defaults to the project's configured URL). |

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST -H "Authorization: Bearer $TESTVIBE_API_KEY" \
  -H "Content-Type: application/json" -d '{}' \
  "$TESTVIBE_SERVER/api/v1/ops/projects/$PROJECT/features/12/generate"
```

{% endtab %}

{% tab title="CLI" %}

```bash
testvibe generate "Login Functionality" --watch
```

{% endtab %}

{% tab title="MCP" %}
Tool **`generate_feature`** — `{ "feature": "Login Functionality" }`. Follow with `wait_for_generation`.
{% endtab %}
{% endtabs %}

## Response

`202 Accepted`

```json
{ "requestId": "a1b2c3d4-…", "featureId": 12 }
```

The feature's status flips to `generating`; track progress via [`get_generation_status`](/testvibe-api/api-reference/generation/get_generation_status.md) and land on `generated` or `failed`.

## Errors

| HTTP            | When                                              |
| --------------- | ------------------------------------------------- |
| `404 not_found` | No such feature in this project.                  |
| `409 conflict`  | Already generating, or the dispatch was rejected. |


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.testvibe.com/testvibe-api/api-reference/generation/generate_feature.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
