OpenAI Compatibility

Use OpenAI SDKs to access Caesar's research capabilities

Caesar provides OpenAI-compatible endpoints that let you use existing OpenAI client libraries to access Caesar’s research API. With minimal code changes, you can integrate Caesar into applications already using the OpenAI SDK.

This compatibility layer is useful for quick integration and testing. For full access to Caesar’s features, we recommend using the native Research API.

Getting started

To use Caesar with the OpenAI SDK:

  1. Point the base URL to https://api.caesar.xyz/compat
  2. Use your Caesar API key
  3. Use caesar-research as the model name
1from openai import OpenAI
2
3client = OpenAI(
4 api_key="YOUR_CAESAR_API_KEY",
5 base_url="https://api.caesar.xyz/compat"
6)
7
8response = client.chat.completions.create(
9 model="caesar-research",
10 messages=[
11 {"role": "user", "content": "What are the latest developments in quantum computing?"}
12 ]
13)
14
15print(response.choices[0].message.content)

Available endpoints

EndpointDescription
POST /compat/chat/completionsChat completions format (recommended)
POST /compat/completionsText completions format

Both endpoints trigger Caesar’s research workflow. The last user message becomes the research query, and the response includes synthesized findings with citations.


Including files in research

Caesar extends the OpenAI chat completions format to support file attachments for document-grounded research. This is a two-step process:

1

Upload files

First, upload your files using the Caesar files endpoint:

$curl -X POST https://api.caesar.xyz/research/files \
> -H "Authorization: Bearer YOUR_CAESAR_API_KEY" \
> -F "file=@document.pdf"

Response:

1{
2 "id": "9c6f8b1a-2a4f-4a35-86b9-0d0b5e25d5e5",
3 "filename": "document.pdf",
4 "size": 245678,
5 "created_at": "2025-01-15T10:30:00Z"
6}
2

Reference files in messages

Include the file ID in your chat completion request using multimodal content parts:

1{
2 "model": "caesar-research",
3 "messages": [
4 {
5 "role": "user",
6 "content": [
7 {
8 "type": "text",
9 "text": "Summarize the key findings from this document"
10 },
11 {
12 "type": "file",
13 "file": {
14 "filename": "document.pdf",
15 "fileData": "9c6f8b1a-2a4f-4a35-86b9-0d0b5e25d5e5"
16 }
17 }
18 ]
19 }
20 ]
21}

Important: The fileData field must contain the Caesar file UUID returned from the upload endpoint, not base64 data or a URL. Files are only supported on /compat/chat/completions, not /compat/completions.

Python example with files

1import requests
2from openai import OpenAI
3
4# Step 1: Upload file
5upload_response = requests.post(
6 "https://api.caesar.xyz/research/files",
7 headers={"Authorization": "Bearer YOUR_CAESAR_API_KEY"},
8 files={"file": open("report.pdf", "rb")}
9)
10file_id = upload_response.json()["id"]
11
12# Step 2: Research with file context
13client = OpenAI(
14 api_key="YOUR_CAESAR_API_KEY",
15 base_url="https://api.caesar.xyz/compat"
16)
17
18response = client.chat.completions.create(
19 model="caesar-research",
20 messages=[
21 {
22 "role": "user",
23 "content": [
24 {"type": "text", "text": "What are the main conclusions in this report?"},
25 {"type": "file", "file": {"filename": "report.pdf", "fileData": file_id}}
26 ]
27 }
28 ]
29)
30
31print(response.choices[0].message.content)

Research configuration

Caesar extends the OpenAI format with a metadata object for fine-tuning research behavior:

1{
2 "model": "caesar-research",
3 "messages": [{"role": "user", "content": "Your query"}],
4 "metadata": {
5 "reasoning_loops": 3,
6 "source_timeout": 60,
7 "reasoning_mode": true,
8 "allow_early_exit": true,
9 "exclude_social": false,
10 "system_prompt": "Focus on peer-reviewed sources"
11 }
12}
ParameterTypeDefaultDescription
reasoning_loopsintegerautoResearch iterations (1-10)
source_timeoutintegerautoSeconds per source (3-180)
reasoning_modebooleanautoUse advanced reasoning models
allow_early_exitbooleanautoComplete early if sufficient
exclude_socialbooleanautoExclude social media sources
system_promptstring-Custom synthesis instructions

When metadata is omitted, Caesar uses auto mode to intelligently configure parameters based on your query. See Research Parameters for details.


Streaming

Enable streaming to receive results as Server-Sent Events:

1stream = client.chat.completions.create(
2 model="caesar-research",
3 messages=[{"role": "user", "content": "Latest AI research trends"}],
4 stream=True
5)
6
7for chunk in stream:
8 if chunk.choices[0].delta.content:
9 print(chunk.choices[0].delta.content, end="")

Response format

Responses follow the OpenAI format with Caesar’s research content:

1{
2 "id": "f2f6e5db-2c7d-4f56-bb0c-5a6b6a7a9b10",
3 "object": "chat.completion",
4 "created": 1705312200,
5 "model": "caesar-research",
6 "choices": [
7 {
8 "index": 0,
9 "message": {
10 "role": "assistant",
11 "content": "Based on current research...\n\n## References\n[1] https://example.com/source1\n[2] https://example.com/source2"
12 },
13 "finish_reason": "stop"
14 }
15 ],
16 "usage": {
17 "prompt_tokens": 0,
18 "completion_tokens": 0,
19 "total_tokens": 0
20 }
21}

Caesar appends a References section to responses with numbered citations linking to source URLs.


Supported parameters

Request fields

FieldSupport
modelAccepted (use caesar-research)
messagesFully supported
promptFully supported (completions endpoint)
streamFully supported
max_tokensAccepted for compatibility
temperatureAccepted for compatibility (0-2)
top_pAccepted for compatibility (0-1)
stopAccepted for compatibility
seedAccepted for compatibility
metadataCaesar extension for research config

Response fields

FieldSupport
idFully supported (Caesar job UUID)
objectFully supported
createdFully supported
modelEcho of request model
choicesAlways length 1
choices[].messageFully supported
choices[].finish_reasonFully supported
usageIncluded (values are 0)

Limitations

No token counting

Usage statistics return 0 for all token fields. Caesar uses research-based pricing rather than token counting.

Single choice

The n parameter is not supported. Responses always contain exactly one choice.

No function calling

Tool/function calling is not supported. Caesar focuses on research synthesis rather than tool use.

Files require chat endpoint

File attachments only work with /compat/chat/completions, not the text completions endpoint.

Ignored parameters

These OpenAI parameters are accepted but have no effect:

  • logprobs, top_logprobs
  • logit_bias
  • presence_penalty, frequency_penalty
  • response_format
  • tools, tool_choice
  • user

Error handling

Errors follow the OpenAI format:

1{
2 "error": {
3 "message": "Invalid API key",
4 "type": "authentication_error"
5 }
6}
StatusMeaning
400Invalid request (missing required fields, invalid parameters)
401Invalid or missing API key
429Rate limit exceeded
500Internal server error
Need the native API?

For full access to Caesar’s features including real-time progress events, collections, and detailed research metadata, use the Research API directly.