Skip to main content

Quickstart

Get your first Ragen API call working in under 5 minutes.

Prerequisites

  • A Ragen AI account (sign up at app.ragen.ai)
  • A project with at least one document uploaded to its knowledge base
  • An API key (we'll create one below)

Step 1: Create an API key

  1. Log in to your Ragen dashboard
  2. Navigate to Settings > API Keys
  3. Click Create API Key
  4. Enter a name (e.g., "My first key") and select the project this key should access
  5. Click Create
  6. Copy the key immediately — it's only shown once
warning

Store your API key securely. It cannot be retrieved after creation — only a masked version is stored for display.

Step 2: Send your first request

Use the Chat API to ask a question against your project's knowledge base:

curl -X POST https://api.ragen.ai/v1/chat \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "What is our refund policy?"
}'

You'll get a JSON response:

{
"text": "Based on your documentation, the refund policy states that customers can request a full refund within 30 days of purchase..."
}

Step 3: Try streaming

For real-time responses, enable streaming with "stream": true:

curl -X POST https://api.ragen.ai/v1/chat \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "Summarize our onboarding process",
"stream": true
}'

The response streams as Server-Sent Events (SSE):

data: {"text":"The "}
data: {"text":"onboarding "}
data: {"text":"process "}
data: {"text":"consists of..."}
data: [DONE]

Step 4: Add page context (optional)

If you're building a contextual chatbot embedded on a webpage, pass the page content as context:

curl -X POST https://api.ragen.ai/v1/chat \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "What does this page say about pricing?",
"context": "<html>...your page content here...</html>"
}'

The AI will use both the page context and the project's knowledge base to answer.

Example: JavaScript / TypeScript

const response = await fetch("https://api.ragen.ai/v1/chat", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.RAGEN_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
content: "What are the main features of our product?",
}),
});

const data = await response.json();
console.log(data.text);

Example: Python

import requests

response = requests.post(
"https://api.ragen.ai/v1/chat",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"content": "What are the main features of our product?",
},
)

data = response.json()
print(data["text"])

What's next?