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

# Ask AI

Use this API to send a text rewriting or processing request to an AI model. The model provider is resolved automatically from the model name prefix.

<Note>
  Customer API keys are stored encrypted in the workspace `aiModelsConfig` and decrypted server-side. Configure your provider API keys in the [Velt Console](https://console.velt.dev) before using this endpoint.
</Note>

# Endpoint

`POST https://api.velt.dev/v2/rewriter/ask-ai`

# Headers

<ParamField header="x-velt-api-key" type="string" required>
  Your API key.
</ParamField>

<ParamField header="x-velt-auth-token" type="string" required>
  Your [Auth Token](/security/auth-tokens).
</ParamField>

# Body

#### Params

<ParamField body="data" type="object" required>
  <Expandable title="properties">
    <ParamField body="model" type="string" required>
      Model name to use for processing. The provider is resolved from the name prefix:

      * `gpt-*`, `o1-*`, `o3-*`, `o4-*` → OpenAI
      * `claude-*` → Anthropic
      * `gemini-*` → Gemini
    </ParamField>

    <ParamField body="prompt" type="string" required>
      System prompt or instruction describing how to process the text.
    </ParamField>

    <ParamField body="text" type="string" required>
      Input text to process.
    </ParamField>
  </Expandable>
</ParamField>

<Note>
  OpenAI reasoning models (`o1-*`, `o3-*`, `o4-*`) use a user-only message format. The `prompt` is prepended to the `text` in a single user message rather than sent as a separate system prompt.
</Note>

#### Supported models (non-exhaustive)

| Provider  | Example models                                                 |
| --------- | -------------------------------------------------------------- |
| OpenAI    | `gpt-4o`, `gpt-4o-mini`, `gpt-4.1`, `o3`, `o3-mini`, `o4-mini` |
| Anthropic | `claude-sonnet-4-0`, `claude-opus-4-0`, `claude-haiku-4-5`     |
| Gemini    | `gemini-2.5-pro`, `gemini-2.5-flash`, `gemini-2.5-flash-lite`  |

## **Example Requests**

#### Rewrite text using Claude

```JSON theme={null}
{
  "data": {
    "model": "claude-3-5-sonnet-20241022",
    "prompt": "Rewrite the following text to be more concise and professional.",
    "text": "Hey so I was just thinking that maybe we could potentially look into making some changes to the way we do things around here."
  }
}
```

#### Rewrite text using GPT-4o

```JSON theme={null}
{
  "data": {
    "model": "gpt-4o",
    "prompt": "Fix the grammar and spelling in the following text.",
    "text": "Their going to the store to by some apples."
  }
}
```

#### Process text using a reasoning model

```JSON theme={null}
{
  "data": {
    "model": "o3-mini",
    "prompt": "Summarize the key points from the following text.",
    "text": "Long document text content goes here..."
  }
}
```

# Response

#### Success Response

```JSON theme={null}
{
  "result": {
    "success": true,
    "text": "The rewritten or processed text returned by the model."
  }
}
```

#### Error Response

```JSON theme={null}
{
  "result": {
    "success": false,
    "error": "No API key configured for provider: OpenAI"
  }
}
```

#### Failure Response

```JSON theme={null}
{
  "error": {
    "message": "ERROR_MESSAGE",
    "status": "INVALID_ARGUMENT"
  }
}
```

<ResponseExample>
  ```js theme={null}
  {
    "result": {
      "success": true,
      "text": "The rewritten or processed text returned by the model."
    }
  }
  ```
</ResponseExample>
