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

# API Reference

> REST API reference

# Overview

The Adaptive REST API provides endpoints for inference, feedback, and interactions.

Base URL: `https://your-adaptive-instance/api/v1`

***

## Completions

### `POST /api/v1/chat/completions`

**Generate chat completion**

Generate a chat completion from a prompt using one model in your use case.
Your prompt messages can include several roles.
This endpoints supports streaming

**Request Body**

<ParamField body="parameters">
  * **stop** (`string[] | null`):
  * **max\_tokens** (`integer<int32> | null`):
  * **temperature** (`number<float> | null`):
  * **top\_p** (`number<float> | null`):
  * **serialized\_python** (`string | null`):
  * **messages** (`ChatMessage[]`) *(required)*:
  * **model** (`string`) *(required)*: can be of the form `{use_case}/{model}` or `{use_case}`. In the latter it will use the default model
  * **stream** (`boolean`):
  * **stream\_options** (`any | null`):
  * **session\_id** (`string<uuid> | null`):
  * **user** (`string<uuid> | null`):
  * **ab\_campaign** (`any | null`):
  * **n** (`integer<int32>`):
  * **labels** (`any | null`):
  * **metadata** (`any | null`):
  * **system\_prompt\_args** (`object | null`): Will be used to render system prompt template
  * **tags** (`string[] | null`):
</ParamField>

**Response** (`ChatResponse`)

a stream will be returned if `streaming = true` in the request

### `POST /api/v1/completions`

**Generate completion**

Generate a completion from a prompt using one model in your use case.
This endpoints supports streaming

**Request Body**

<ParamField body="parameters">
  * **stop** (`string[] | null`):
  * **max\_tokens** (`integer<int32> | null`):
  * **temperature** (`number<float> | null`):
  * **top\_p** (`number<float> | null`):
  * **serialized\_python** (`string | null`):
  * **prompt** (`string`) *(required)*:
  * **model** (`string`) *(required)*: can be of the form `{use_case}/{model}` or `{use_case}`. In the latter it will use the default model
  * **stream** (`boolean`):
  * **session\_id** (`string<uuid> | null`):
  * **user** (`string<uuid> | null`):
  * **ab\_campaign** (`any | null`):
  * **n** (`integer<int32>`):
  * **metadata** (`any | null`):
  * **labels** (`any | null`):
  * **tags** (`string[] | null`):
</ParamField>

**Response** (`GenerateResponse`)

a stream will be returned if `streaming = true` in the request

***

## Embeddings

### `POST /api/v1/embeddings`

**Generate embeddings**

**Request Body**

<ParamField body="parameters">
  * **input** (`string`) *(required)*:
  * **model** (`string`) *(required)*: can be of the form '{use_case}/{model}' or '{use_case}'. In the latter it will use the default model
  * **encoding\_format** (`any | null`):
  * **dimensions** (`integer<int32> | null`):
  * **user** (`string<uuid> | null`):
</ParamField>

**Response** (`EmbeddingsResponseList`)

***

## Feedback

### `POST /api/v1/feedback`

**Add feedback**

Register a feedback about a previous interaction (chat or generation)

**Request Body**

<ParamField body="parameters">
  * **value** (`any`) *(required)*: If the metric is Bool, accepts `0`, `1`, `true` or `false`
    If the metric is Scalar, accepts number
  * **completion\_id** (`string<uuid>`) *(required)*:
  * **metric** (`IdOrKey`) *(required)*:
  * **user\_id** (`string<uuid> | null`):
  * **reason** (`any | null`):
  * **details** (`string | null`):
</ParamField>

**Response** (`FeedbackOutput`)

feedback recorded

### `POST /api/v1/comparison`

**Add preference**

Register preference between two interactions according to a criteria.
Both interactions should share the same prompt.

**Request Body**

<ParamField body="parameters">
  * **metric** (`IdOrKey`) *(required)*:
  * **prompt** (`string | null`): Required (or messages) when using raw text for completion, ignored if using ids
  * **messages** (`ChatMessage[] | null`): Required (or prompt) when using raw text for completion, ignored if using ids
  * **preferred\_completion** (`CompletionIdOrText`) *(required)*:
  * **other\_completion** (`CompletionIdOrText`) *(required)*:
  * **tied** (`any | null`):
  * **use\_case** (`any | null`):
  * **user\_id** (`string<uuid>`) *(required)*:
</ParamField>

**Response** (`ComparisonOutput`)

Comparison recorded

***

## Interactions

### `POST /api/v1/interactions`

**Add interaction**

Import an interaction in your use case. You can also include feedback about the interaction

**Request Body**

<ParamField body="parameters">
  * **model\_service** (`IdOrKey`) *(required)*:
  * **use\_case** (`IdOrKey`) *(required)*:
  * **prompt** (`string | null`):
  * **messages** (`ChatMessage[] | null`):
  * **completion** (`string`) *(required)*:
  * **feedbacks** (`InteractionFeedback[]`):
  * **user** (`string<uuid> | null`):
  * **session\_id** (`string<uuid> | null`):
  * **created\_at** (`any | null`):
  * **ab\_campaign** (`any | null`):
  * **labels** (`any | null`):
</ParamField>

**Response** (`AddInteractionsResponse`)

Interaction recorded
