# RAG Chat Completion

`POST https://api.vultrinference.com/v1/chat/completions/RAG`

Create a chat completion with context retrieved from items or files in a vector store collection. Reasoning effort, thinking budget, and the express variant follow the Chat Completions behavior.

## Body (application/json)

- `collection` (string, required): The [vector store collection](#operation/list-vector-stores) to search for relevant context.
- `model` (string, required): The [model](#operation/list-models) that will be inferred for chat completion. A `-normalize` suffix is accepted for compatibility and ignored; every response is normalized.
- `messages` (array of objects, required): The message context to use for the chat completion request, separated by system, user, assistant, tool, and developer roles. [at least 1 items]
  - `role` (string): The role of the author of this message. [system, assistant, user, tool, developer]
  - `content` (string or array of objects): The contents of the message: a string, or an array of content parts (text, images, audio, video and documents). Media parts are accepted on `user` messages. See `chat-content-part` for documents: they are converted to text, which becomes part of the prompt.
- `max_tokens` (integer): Deprecated name for `max_completion_tokens`. If both are sent, `max_completion_tokens` takes precedence.
- `max_completion_tokens` (integer): Maximum completion tokens, including reasoning and visible output. [default 32768, at least 1]
- `reasoning_effort` (string): Shorthand for `reasoning.effort`. Configured models map this level to their supported reasoning control. [ultra, max, xhigh, high, medium, low, minimal, none]
- `reasoning` (object): Reasoning controls. Configured models map effort through their database profile. Models advertising `reasoning.supports_max_tokens: true` in `/v1/models?format=openrouter` (a `max_tokens` property under the `reasoning` parameter in the default list) enforce the budget; other models accept it without enforcing it.
  - `effort` (string) [ultra, max, xhigh, high, medium, low, minimal, none]
  - `enabled` (boolean): When false, sets effort to `none`.
  - `summary` (string): Accepted but not supported by the current engines. [auto, concise, detailed]
  - `max_tokens` (integer): Thinking-token budget. Must be below the effective completion limit so the model has room to answer. Ignored when thinking is disabled or a final assistant message is being continued. [at least 1]
- `n` (integer): The number of chat completion choices to generate for each input message. [default 1]
- `seed` (integer): If you would like a different response from the same message, changing the seed will change the response. A null value generates a random seed.
- `temperature` (number (float)): A value between 0.0 and 2.0 that controls the randomness of the model's output. When set closer to 1, such as 0.8, the outcome is more unpredictable and creative. Values nearing 0, like 0.2, produce more predictable and less creative results. A temperature of zero requests greedy decoding; exact reproducibility depends on the model engine. [default 1, range 0–2]
- `top_p` (number (float)): A value between 0.0 and 1.0 that controls the probability of the model generating a particular token. A higher value will result in more diverse outputs, while a lower value will result in more repetitive outputs. [default 1, range 0–1]
- `stop` (string or array of strings): The strings the model stops generating at, up to 4. A single string is accepted as shorthand for a one-item array.
- `frequency_penalty` (number (float)): A value between -2.0 and 2.0 that controls how much the model penalizes generating repetitive responses. [default 0, range -2–2]
- `presence_penalty` (number (float)): A value between -2.0 and 2.0 that controls how much the model penalizes generating responses that contain certain words or phrases. [default 0, range -2–2]
- `stream` (boolean): Indicates whether the response should be streamed.
- `logprobs` (boolean): Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.
- `top_logprobs` (integer): An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. Optional: `logprobs: true` alone returns the sampled token's log probability. Requires `logprobs` to be true. [range 0–20]
- `tool_choice` (string or object): Controls which (if any) tool is called by the model. A tool choice other than `none` requires `tools`.
- `tools` (array of objects): A list of function tools the model may call.
  - `type` (string): The type of the tool. Currently, only `function` is supported.
  - `function` (object): An object representing a function for use with chat completion tool calling.
    - `name` (string): The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64
    - `description` (string): A description of what the function does, used by the model to choose when and how to call the function.
    - `parameters` (object): The parameters the functions accepts, described as a JSON Schema object.
    - `strict` (boolean): Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`.

## Responses

- `200`: OK (chat-completion-response-payload)
- `400`: Bad Request, including a request that failed validation (the message names the rejected field) (error-payload)
- `401`: The API key is missing, unknown or not active. Send it as Authorization: Bearer <key>. (error-payload)

## Example

```bash
curl https://api.vultrinference.com/v1/chat/completions/RAG \
  -H "Authorization: Bearer $VULTR_INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash",
    "collection": "handbook",
    "messages": [
      {
        "role": "user",
        "content": "How many vacation days do new hires get?"
      }
    ]
  }'
```

```python
import os
import requests

response = requests.post(
    "https://api.vultrinference.com/v1/chat/completions/RAG",
    headers={"Authorization": f"Bearer {os.environ['VULTR_INFERENCE_API_KEY']}"},
    json={
        "model": "deepseek-v4.1-flash",
        "collection": "handbook",
        "messages": [
            {
                "role": "user",
                "content": "How many vacation days do new hires get?",
            },
        ],
    },
)
print(response.json())
```

```javascript
const response = await fetch("https://api.vultrinference.com/v1/chat/completions/RAG", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.VULTR_INFERENCE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "deepseek-v4.1-flash",
    "collection": "handbook",
    "messages": [
      {
        "role": "user",
        "content": "How many vacation days do new hires get?"
      }
    ]
  }),
});
console.log(await response.json());
```
