> ## 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.

# Endpoint

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

# Headers

**x-velt-api-key** `string` *required*

Your API key.

**x-velt-auth-token** `string` *required*

Your [Auth Token](https://velt.dev/docs/security/auth-tokens.md).

# Body

#### Params

**data** `object` *required*

**properties**

**model** `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

**prompt** `string` *required*

System prompt or instruction describing how to process the text.

**text** `string` *required*

Input text to process.

> [!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.

#### 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"
  }
}
```

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.