RAG Chat Completions

Drop-in OpenAI and Anthropic-compatible endpoints that automatically search your YourGPT knowledgebase before generating a response.

YourGPT's RAG Chat Completions endpoints let you use the OpenAI SDK or Anthropic SDK you already know — but with your knowledgebase automatically available as a tool. Just point the SDK's baseURL at YourGPT and add a yourgpt:knowledgebase server tool. The API handles retrieval, injects context, and returns the AI answer plus the source chunks used.

Requests are billed per token against your credit balance. Hourly request caps depend on your plan: Professional (200 req/hr) and Advanced / Agency (1000 req/hr).

Endpoints

SDKEndpoint
OpenAI SDKPOST https://api.yourgpt.ai/chatbot/v1/openai/chat/completions
Anthropic SDKPOST https://api.yourgpt.ai/chatbot/v1/anthropic/v1/messages

Authentication: pass your project API key (apk-...) as the SDK's API key — it is forwarded automatically in the Authorization: Bearer or x-api-key header.

Choosing a model

Each endpoint takes models from its own provider: gpt-* (plus the o1 and o3 families) on the OpenAI endpoint, claude-* on the Anthropic endpoint.

To see which models your plan can use, call:

curl -X POST https://api.yourgpt.ai/chatbot/v1/getSupportedModels

Pass the value from the response as your model. Models marked tier: 1 require an Advanced plan or above.

Models change as new ones launch and old ones retire — read the list from this endpoint instead of hardcoding it.

How it works

Point your SDK at YourGPT and declare a yourgpt:knowledgebase tool. The LLM decides when it needs to search; YourGPT runs the retrieval server-side and feeds the results back into the conversation. You get the standard OpenAI / Anthropic response shape plus a sources array listing everything that was retrieved.

You can also pass your own tools alongside the YourGPT ones — those are handed back to you to execute, exactly as the native APIs do.

Quick start

from openai import OpenAI

client = OpenAI(
    api_key="apk-your-api-key",
    base_url="https://api.yourgpt.ai/chatbot/v1/openai",
)

response = client.chat.completions.create(
    model="gpt-5.6-terra",
    messages=[
        {"role": "system", "content": "You are a helpful support agent."},
        {"role": "user", "content": "How do I reset my password?"},
    ],
    tools=[
        {
            "type": "yourgpt:knowledgebase",
            "parameters": {"limit": 5},
        }
    ],
)

print(response.choices[0].message.content)
print(response.model_dump()["sources"])  # what was retrieved
import anthropic

client = anthropic.Anthropic(
    api_key="apk-your-api-key",
    base_url="https://api.yourgpt.ai/chatbot/v1/anthropic",
)

response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    system="You are a helpful support agent.",
    messages=[
        {"role": "user", "content": "How do I reset my password?"},
    ],
    tools=[
        {
            "type": "yourgpt:knowledgebase",
            "parameters": {"limit": 5},
        }
    ],
)

print(response.content[0].text)
print(response.model_dump()["sources"])  # what was retrieved
curl -X POST https://api.yourgpt.ai/chatbot/v1/openai/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer apk-your-api-key" \
  -d '{
    "model": "gpt-5.6-terra",
    "messages": [
      {"role": "system", "content": "You are a helpful support agent."},
      {"role": "user", "content": "How do I reset my password?"}
    ],
    "tools": [
      {"type": "yourgpt:knowledgebase", "parameters": {"limit": 5}}
    ]
  }'
curl -X POST https://api.yourgpt.ai/chatbot/v1/anthropic/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: apk-your-api-key" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "system": "You are a helpful support agent.",
    "messages": [
      {"role": "user", "content": "How do I reset my password?"}
    ],
    "tools": [
      {"type": "yourgpt:knowledgebase", "parameters": {"limit": 5}}
    ]
  }'

Explore the endpoints

On this page