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

# AI API

> LLM-backed analysis, translation, suggestion, classification, and content generation. The same primitives that power the Orbit dashboard, exposed for your own apps.

# AI API

A focused set of LLM-backed primitives that the Orbit platform uses internally — message analysis, reply suggestion, intent classification, summarization, content generation, and a small knowledge-base utility. All LLM requests route through Orbit's partner-vetted Anthropic gateway — you don't manage model-provider keys directly.

**Base path:** `/api/v1/ai`

**Authentication:** API key (`X-API-Key`) or session JWT. Service-to-service callers (with `X-Internal-Token`) get the `developer` role to cap blast radius.

## Analysis & insight

| Method | Path                                | Purpose                            |
| ------ | ----------------------------------- | ---------------------------------- |
| `POST` | `/api/v1/ai/analyze`                | General message / content analysis |
| `POST` | `/api/v1/ai/analyze-message/{id}`   | Analyze a specific message by ID   |
| `POST` | `/api/v1/ai/classify-intent`        | Classify a message's intent        |
| `POST` | `/api/v1/ai/summarize-conversation` | Summarize a long conversation      |
| `POST` | `/api/v1/ai/dashboard-insights`     | Generate dashboard insight prose   |

## Generation & rewriting

| Method | Path                          | Purpose                                   |
| ------ | ----------------------------- | ----------------------------------------- |
| `POST` | `/api/v1/ai/suggest-reply`    | Draft a reply to an inbound message       |
| `POST` | `/api/v1/ai/generate-content` | Generate marketing content from a brief   |
| `POST` | `/api/v1/ai/improve-text`     | Rewrite for tone / clarity / length       |
| `POST` | `/api/v1/ai/translate`        | Translate to a target language            |
| `POST` | `/api/v1/ai/compose-campaign` | Compose a multi-step campaign from a goal |
| `POST` | `/api/v1/ai/optimize-channel` | Recommend best channel/time for a contact |

## Inference building blocks

Two general-purpose endpoints let you run embeddings and chat inference on the same managed fleet — and the same wallet — as the rest of your Orbit comms. Both are OpenAI-compatible, so existing SDKs drop in by pointing their base URL at `/api/v1/ai`.

| Method | Path                          | Purpose                                          |
| ------ | ----------------------------- | ------------------------------------------------ |
| `POST` | `/api/v1/ai/embeddings`       | Generate embedding vectors for one or more texts |
| `POST` | `/api/v1/ai/chat/completions` | Run a chat completion (general inference)        |

<Note>
  Both endpoints call a model provider on every request and are billed per token, metered to your workspace wallet. They share the same rate limit as the other AI routes.
</Note>

### Embeddings

`POST /api/v1/ai/embeddings` returns one vector per input. Send `input` as a single string, or as an array of up to 96 strings (each 1–10,000 characters) to embed a batch in one request.

```bash theme={null}
curl -X POST https://api.orbit.devotel.io/api/v1/ai/embeddings \
  -H "X-API-Key: dv_live_sk_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "input": ["order status", "refund policy"]
  }'
```

| Field   | Type                   | Required | Notes                                              |
| ------- | ---------------------- | -------- | -------------------------------------------------- |
| `input` | `string` or `string[]` | yes      | One text, or up to 96 texts (each 1–10,000 chars). |

The response carries the vectors and per-request token usage under `data`. A malformed body (missing `input`, an empty string, or more than 96 items) returns `400`.

### Chat completions

`POST /api/v1/ai/chat/completions` is OpenAI-compatible. Point any OpenAI SDK at your `/api/v1/ai` base URL — the SDK appends `/chat/completions` — and send a `messages` array. OpenAI model ids are remapped to the platform's managed model, so you don't manage provider keys.

```bash theme={null}
curl -X POST https://api.orbit.devotel.io/api/v1/ai/chat/completions \
  -H "X-API-Key: dv_live_sk_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      { "role": "system", "content": "You are a concise support assistant." },
      { "role": "user", "content": "Summarize our refund policy in one line." }
    ]
  }'
```

| Field             | Type       | Required | Notes                                                                                      |
| ----------------- | ---------- | -------- | ------------------------------------------------------------------------------------------ |
| `messages`        | `object[]` | yes      | 1–50 turns; each has `role` (`system`/`user`/`assistant`) and `content` (1–100,000 chars). |
| `model`           | `string`   | no       | Optional model id; OpenAI ids are remapped to the platform's fast tier.                    |
| `temperature`     | `number`   | no       | Sampling temperature, `0`–`2`.                                                             |
| `max_tokens`      | `integer`  | no       | Output token cap, `1`–`8192`.                                                              |
| `response_format` | `object`   | no       | Set `{ "type": "json_object" }` to force JSON output (default `text`).                     |

The completion and token usage are returned under `data`. A body missing `messages` (or with an out-of-range field) returns `400`.

## Knowledge base

An embedded, org-wide knowledge base: ingest documents (upload, URL, markdown, or a bulk help-center import), keep them fresh with a staleness scorecard and per-document verification, and query them with raw semantic search or a grounded answer with citations. For a separately provisioned, per-knowledge-base store, use the [Knowledge Bases API](/api-reference/knowledge-bases) instead.

| Method   | Path                                   | Purpose                                                                             | Request                                                                                                                                         |
| -------- | -------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET`    | `/api/v1/ai/kb/documents`              | List embedded KB documents (keyset-paged)                                           | Query: `cursor`, `limit` (1–100, default 100)                                                                                                   |
| `POST`   | `/api/v1/ai/kb/documents`              | Upload or import a document                                                         | Multipart file, **or** JSON `{ "source_type": "url", "source_url", "name"?, "metadata"? }` / `{ "source_type": "markdown", "name", "content" }` |
| `POST`   | `/api/v1/ai/kb/import/help-center`     | Bulk-import a public Zendesk Guide help center — one document per published article | JSON `{ "subdomain", "provider"?, "locale"?, "name_prefix"?, "max_articles"? (1–1000, default 250) }`                                           |
| `GET`    | `/api/v1/ai/kb/documents/{id}`         | Get a document                                                                      | Path: `id` (UUID)                                                                                                                               |
| `DELETE` | `/api/v1/ai/kb/documents/{id}`         | Delete a document and its vectors                                                   | Path: `id` (UUID)                                                                                                                               |
| `POST`   | `/api/v1/ai/kb/documents/{id}/reindex` | Force reindex                                                                       | Path: `id` (UUID)                                                                                                                               |
| `POST`   | `/api/v1/ai/kb/documents/{id}/verify`  | Stamp a document as reviewed and still accurate (`last_verified_at`)                | Path: `id` (UUID)                                                                                                                               |
| `GET`    | `/api/v1/ai/kb/staleness`              | Org-wide freshness scorecard — stale-document counts by reason                      | Query: `limit` (1–1000, default 25)                                                                                                             |
| `GET`    | `/api/v1/ai/kb/connectors`             | Browse the knowledge-connector catalog                                              | Query: `category`?, `status`?, `search`?                                                                                                        |
| `GET`    | `/api/v1/ai/kb/connectors/{id}`        | Get one connector plus its activation detail                                        | Path: `id` (connector slug)                                                                                                                     |
| `POST`   | `/api/v1/ai/kb/search`                 | Semantic search across documents (raw chunks + scores)                              | JSON `{ "query", "limit"? (1–20, default 5), "threshold"? }`                                                                                    |
| `POST`   | `/api/v1/ai/kb/answers`                | Grounded answer with citations and a confidence score                               | JSON `{ "question", "knowledge_base_ids"?, "limit"? (1–10, default 8), "threshold"?, "min_confidence"?, "language"? }`                          |

## Example — suggest a reply

```bash theme={null}
curl -X POST https://api.orbit.devotel.io/api/v1/ai/suggest-reply \
  -H "X-API-Key: dv_live_sk_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "conversation_id": "conv_abc"
  }'
```

## See also

* [AI Agents API](/api-reference/agents) — full conversational agents with memory, tools, and deployment
* [Knowledge Bases API](/api-reference/knowledge-bases) — multi-doc RAG store
