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

# Streaming AI

> Streaming LLM outputs right away to your application without waiting for the entire response.

## Overview

The Chat Completions API is designed as a standard interface for integrating Large Language Models (LLMs) into your application. It is fully compatible with OpenAI’s Chat Completions API format, making integration straightforward for teams familiar with OpenAI, Claude, or similar providers.

In addition to the standard fields, Promptrun requires a `model` property in the request body. You can choose from a variety of supported models. Visit the [Models page](https://docs.promptrun.ai/models) to see all available models along with usage costs and capabilities.

## Authentication

Use your API key to authenticate requests to this endpoint. You can find or create your API key in the [Promptrun dashboard](https://app.promptrun.ai).

```bash theme={null}
curl -X POST https://api.promptrun.ai/v1/chat/completions \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-3.5-haiku",
    "messages": [
      { "role": "system", "content": "You are a helpful assistant." },
      { "role": "user", "content": "Tell me a fun fact about space." }
    ],
    "temperature": 0.5,
    "top_p": 1,
    "stream": false
  }'
```

## Example Conversation Flow

To maintain context across multiple messages, pass the full conversation history in the `messages` array.

```json theme={null}
{
  "model": "anthropic/claude-3.5-haiku",
  "messages": [
    { "role": "system", "content": "You are a helpful assistant." },
    { "role": "user", "content": "Tell me a fun fact about space." },
    {
      "role": "assistant",
      "content": "Sure! Did you know that Venus spins in the opposite direction to most planets?"
    },
    { "role": "user", "content": "Wow, why is that?" }
  ],
  "temperature": 0.7,
  "top_p": 1,
  "stream": false
}
```

This allows the model to generate coherent responses based on the entire conversation.

## Available Models

For a full list of supported models and pricing information, visit: [Models](https://docs.promptrun.ai/models)

## Response Format

The response from the API is in the same format as OpenAI's, Claude's and Gemini's Chat Completions API. The response includes the model's response, the model's name, and the model's usage information.

```json theme={null}
{
  "id": "chatcmpl-1234567890",
  "object": "chat.completion",
  "created": 1715325600,
  "model": "anthropic/claude-3.5-haiku",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Sure! Did you know that Venus spins in the opposite direction to most planets?"
      }
    }
  ]
}
```
