# RavChat API

> An OpenAI-compatible API for the RavChat agent — sourced Torah answers from a chassidic agent, not a persona-prompted chatbot.


Point any OpenAI client at `https://api.rav.chat/v1` with a RavChat API key and you get the **RavChat agent**: each request runs a real agent turn that can consult sources, work in a project workspace, and produce files.

<CodeGroup>

```python Python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.rav.chat/v1",
    api_key="sk-rav-...",  # create one at app.rav.chat → Settings → API Keys
)

stream = client.chat.completions.create(
    model="ravchat",
    messages=[{"role": "user", "content": "What does the Tanya say about simcha?"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")
```

```javascript Node
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.rav.chat/v1",
  apiKey: "sk-rav-...",
});

const stream = await client.chat.completions.create({
  model: "ravchat",
  messages: [{ role: "user", content: "What does the Tanya say about simcha?" }],
  stream: true,
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
```

```bash curl
curl https://api.rav.chat/v1/chat/completions \
  -H "Authorization: Bearer sk-rav-..." \
  -H "Content-Type: application/json" \
  -d '{"model":"ravchat","messages":[{"role":"user","content":"What does the Tanya say about simcha?"}]}'
```

</CodeGroup>

## What's different from OpenAI

RavChat answers come from an **agent**, not a bare model. Three practical consequences:

<CardGroup cols={3}>
  <Card title="Turns can take minutes" icon="clock">
    Each request runs a real agent turn. Use `stream: true` — the stream starts immediately and stays alive with SSE keep-alives.
  </Card>
  <Card title="Every response says where it ran" icon="folder-tree">
    The `x_ravchat` block (and `x-ravchat-*` headers) carry the project, session, and any files the agent produced. Missing context is auto-created and the ids are returned.
  </Card>
  <Card title="Billing is in credits" icon="coins">
    `usage.cost` is the RavChat credits charged for the turn, from the same pools as your app plan.
  </Card>
</CardGroup>

## Start here

<CardGroup cols={2}>
  <Card title="Authentication" icon="key" href="/guides/authentication">
    API keys, project binding, and scopes.
  </Card>
  <Card title="Chat completions" icon="message" href="/guides/chat-completions">
    Run an agent turn — requests, the response shape, and `x_ravchat`.
  </Card>
  <Card title="Streaming" icon="bolt" href="/guides/streaming">
    The recommended mode for every integration.
  </Card>
  <Card title="API Reference" icon="code" href="/api-reference/chat/create-chat-completion">
    Interactive playground for every endpoint.
  </Card>
</CardGroup>

## Works with your stack

The OpenAI JS/Python SDKs, LangChain `ChatOpenAI`, LiteLLM (keep the `/v1` suffix), and the Vercel AI SDK (`createOpenAICompatible`) all work unmodified. See [Compatibility](/guides/compatibility) for the honest parameter table.
