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

# POST /generate

> Generate an AI response based on conversation history.

Use `/generate` for direct ThinkFeel requests. Send a persona ID and full message history. The response returns the selected final reply and optional alternatives.

```text theme={null}
POST https://playground.curvelabs.org/api/v1/generate
```

## Headers

| Header          | Type   | Required    | Description                                           |
| --------------- | ------ | ----------- | ----------------------------------------------------- |
| `Content-Type`  | string | Yes         | Must be `application/json`                            |
| `x-api-key`     | string | Conditional | API key for API-key billing                           |
| `Authorization` | string | Conditional | Alternative bearer format: `Bearer YOUR_API_KEY_HERE` |

## Body parameters

| Parameter              | Type                 | Required | Description                                                                      |
| ---------------------- | -------------------- | -------- | -------------------------------------------------------------------------------- |
| `personaId`            | string               | Yes      | Persona UUID provided during onboarding                                          |
| `messages`             | array                | Yes      | Conversation messages to use as context                                          |
| `messages[].role`      | string               | Yes      | `user`, `assistant`, `system`, or `developer`                                    |
| `messages[].content`   | string or text array | Yes      | Plain text, or an array of text parts shaped as `{ type: "text", text: string }` |
| `messages[].timestamp` | number or string     | No       | Optional timestamp; `createdAt` and `created_at` are also accepted               |
| `includeVariations`    | boolean              | No       | Return alternative reply choices. Defaults to `false`                            |

<Info>
  `messages[]` must contain at least one message. The last message must use the `user` role; `assistant` cannot be the last
  message. `system` and `developer` messages are accepted as text-only context before the final user message. Only text
  content is supported.
</Info>

## Request

```bash theme={null}
curl -X POST https://playground.curvelabs.org/api/v1/generate \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY_HERE" \
  -d '{
    "personaId": "YOUR_PERSONA_ID",
    "messages": [
      {
        "role": "user",
        "content": "Hello!"
      }
    ]
  }'
```

## Default response

When `includeVariations` is `false`, the API returns the final reply and chunks.

```json theme={null}
{
  "status": "success",
  "result": {
    "finalReply": "hey! what's up?",
    "chunks": ["hey! what's up?"]
  }
}
```

## Response with variations

When `includeVariations` is `true`, the API may include `replyChoices`.

```json theme={null}
{
  "status": "success",
  "result": {
    "finalReply": "hey! what's up?",
    "chunks": ["hey! what's up?"],
    "replyChoices": ["hey! what's up?", "hi there! how's it going?", "hey! good to hear from you"]
  }
}
```

API-key `/generate` responses may also include a top-level `rateLimits` array when rate-limit metadata is available for your account.

## SDK and CLI notes

<Warning>
  The ThinkFeel SDK wraps `/api/v1/generate` and `/api/v1/personify`. It does not wrap `/api/v1/completions`, which remains
  the OpenAI-compatible endpoint.
</Warning>

The ThinkFeel SDK package is currently `0.1.6` and supports:

* `new ThinkFeel({ apiKey, personaId, baseUrl? })`
* `generate({ messages, includeVariations? })`
* `personify({ raw })`

When setting SDK `baseUrl`, pass only the site origin, such as `https://playground.curvelabs.org`; the SDK appends `/api/v1` internally.
