- Choose Your Use Case
- Use Case 1: Large Context - Live Embeddings Responses
- What It Does
- Use Cases
- Integration Options
- Use Case 2: Data Lake RAG
- What It Does
- Use Cases
- How It Works
- Prerequisites
- Get Your API Credentials
- Getting Started: Large Context - Live Embeddings Responses
- Python SDK
- Installation
- Quick Start: Your First Request
- System Prompts: Custom Roles or Captain’s Default
- Streaming Responses
- Processing Large Text Documents
- JavaScript/TypeScript SDK
- Installation
- Quick Start: Your First Request
- Streaming Responses
- Processing Large Text Documents
- Vercel AI SDK
- Installation
- Quick Start: Your First Request
- Non-Streaming Responses
- Tool Calling
- Processing Large Contexts
- Next Steps: SDK
- Getting Started with HTTP API
- Authentication
- Quick Start: Your First Request
- HTTP API in Different Languages
- Streaming Responses
- Processing Large Text Documents
- HTTP Response Formats
- Next Steps: HTTP API
- Getting Started: Data Lake RAG
- Prerequisites: Set Up Your Cloud Storage Bucket
- AWS S3 Bucket Setup
- Google Cloud Storage Bucket Setup
- Step 1: Create a Database
- Step 2: Index Your Cloud Storage
- Option A: Index AWS S3 Bucket
- Option B: Index Google Cloud Storage Bucket
- Step 3: Monitor Indexing Progress
- Step 4: Query Your Indexed Data
- Step 5: Query with Streaming (Optional)
- Next Steps: Data Lake Integration
- Important Concepts
- Environment Scoping
- Supported File Types
- Rate Limits
- Comparison: SDK vs HTTP API vs Data Lake
- Using the Demo Client
- Next Steps
- For SDK Users:
- For HTTP API Users:
- For Data Lake Users:
- Additional Resources:
- Getting Help
Getting Started with Captain
Welcome to Captain! We offer two distinct use cases to help you work with large amounts of data using AI.
Choose Your Use Case
Captain offers two main use cases. Choose the one that fits your needs:
Process unlimited text in a single LLM request via OpenAI-compatible API
Full RAG infrastructure for unstructured data in S3, GCS, or Azure Blob
Use Case 1: Large Context - Live Embeddings Responses
Process unlimited text through OpenAI/Vercel-compatible APIs
Perfect for developers who need to analyze large documents, codebases, or text data without token limits. No infrastructure setup required.
What It Does
- Unlimited context window - Process millions of tokens in a single request
- OpenAI SDK compatible - Drop-in replacement, just change the base URL
- Vercel AI SDK support - Works with Next.js and React applications
- Real-time streaming - Get responses as they’re generated
- No storage required - Stateless processing, no databases to manage
Use Cases
- Analyze entire codebases or log files
- Summarize lengthy legal documents or contracts
- Process large CSV/JSON data files
- Answer questions about long-form content
- Generate insights from extensive research papers
Integration Options
Get Started with Large Context →
Use Case 2: Data Lake RAG
Full-fledged RAG infrastructure for unstructured data
Perfect for organizations with documents stored in cloud storage who need persistent, searchable knowledge bases with AI-powered querying.
What It Does
- Connect cloud storage - Index AWS S3, Google Cloud Storage, or Azure Blob
- Automatic document processing - Extract and chunk PDFs, DOCX, XLSX, images, and more
- Vector search + AI answers - Natural language queries with source citations
- Persistent databases - Query across thousands of files anytime
- File tracking - Know exactly which documents contain what information
Use Cases
- Enterprise knowledge bases and documentation search
- Legal document management and contract analysis
- Compliance and audit document retrieval
- Customer support knowledge bases
- Research paper and patent search
- Code repository semantic search
How It Works
Get Started with Data Lake RAG →
Prerequisites
Get Your API Credentials
You’ll need:
- API Key from Captain API Studio (format:
cap_dev_...,cap_prod_...) - Organization ID (UUID format, also available in the Studio)
Store your API key securely, such as in an environment variable:
macOS / Linux
Windows
Getting Started: Large Context - Live Embeddings Responses
Captain provides OpenAI SDK compatibility for unlimited context processing. Choose your integration:
Python SDK
Perfect for developers already using the OpenAI Python SDK - Captain is a drop-in replacement.
Installation
Quick Start: Your First Request
Important: Provide context via extra_body and use system messages for instructions:
System Prompts: Custom Roles or Captain’s Default
Captain gives you full control over the AI’s persona and behavior through system prompts:
Option 1: Define Your Own Role - Use system messages to make the AI assume specific roles or behaviors:
Option 2: Use Captain’s Default - Omit the system message to use Captain’s built-in persona:
Key Points:
- System messages = AI instructions (define role, tone, behavior)
- User messages = Your actual questions or requests
extra_body.captain.context= Large documents/data to analyze- System prompts are completely optional - Captain has intelligent defaults
Streaming Responses
Get responses in real-time as they’re generated:
Processing Large Text Documents
Captain handles unlimited context automatically - no size limits:
Note: For processing PDFs, images, or other file formats, use Data Lake Integration which supports 30+ file types including PDF, DOCX, images, and more.
JavaScript/TypeScript SDK
Perfect for developers using Node.js, Deno, or Bun - Captain is a drop-in replacement for OpenAI.
Installation
Install the OpenAI SDK using npm or your preferred package manager:
Quick Start: Your First Request
Important: Provide context via experimental_providerOptions.openai.extra_body.captain.context. Create a file called example.mjs with the following code:
Execute the code with node example.mjs (or the equivalent command for Deno or Bun).
Streaming Responses
Get responses in real-time as they’re generated:
Processing Large Text Documents
Captain handles unlimited context automatically - no size limits:
Note: For processing PDFs, images, or other file formats, use Data Lake Integration which supports 30+ file types including PDF, DOCX, images, and more.
Vercel AI SDK
Perfect for developers using Vercel’s AI SDK - Captain works seamlessly with the OpenAI provider.
Installation
For tool calling, also install zod:
Quick Start: Your First Request
Important: Vercel AI SDK requires context to be passed via a custom header X-Captain-Context that must be base64-encoded (HTTP headers cannot contain newlines).
Why base64 encoding? HTTP headers cannot contain newlines or special characters, so context must be base64-encoded before being sent in the X-Captain-Context header.
Alternative: For production use, we recommend the OpenAI SDK with extra_body parameter - it’s more reliable and doesn’t require base64 encoding.
Non-Streaming Responses
For non-streaming responses, use generateText():
Tool Calling
Define tools with Vercel AI SDK’s zod schema format:
Processing Large Contexts
⚠️ Important: HTTP headers have size limits (~4-8KB). For contexts larger than ~4KB after base64 encoding:
Option 1: Use the OpenAI JavaScript SDK with extra_body (recommended)
Option 2: Use the /v1/chat/completions/upload endpoint with FormData:
For complete documentation, see JavaScript/TypeScript SDK Guide.
Next Steps: SDK
- Full SDK Documentation - Complete reference for Python, JavaScript, and Vercel AI SDK
- Learn about all supported parameters
- Explore advanced streaming options
- Understand unlimited context processing
Getting Started with HTTP API
Perfect for developers making HTTP requests with any language or framework. The HTTP API provides direct access to Captain’s Large Context - Live Embeddings Responses without requiring SDKs.
Authentication
All HTTP API requests require authentication via headers:
Quick Start: Your First Request
Use the /v1/responses endpoint to process text and ask questions:
Key Parameters:
input: Your context/document text (required)query: The question to ask about the context (required)stream: Set to'true'for real-time streaming (optional)
HTTP API in Different Languages
Python (requests):
JavaScript (fetch):
cURL:
Streaming Responses
Get responses in real-time as they’re generated using Server-Sent Events (SSE):
Python:
JavaScript:
cURL:
Processing Large Text Documents
Captain handles unlimited context - send text files of any size:
Note: For processing PDFs, images, or other file formats, use Data Lake Integration which supports 30+ file types.
HTTP Response Formats
Non-Streaming Response:
Streaming Response (SSE):
Error Response:
Next Steps: HTTP API
- Full HTTP API Documentation - Complete reference including
/v1/responsesendpoint - Learn about all available parameters
- Explore error handling
- Understand rate limits
Getting Started: Data Lake RAG
Full-fledged RAG infrastructure for indexing cloud storage buckets (AWS S3, Google Cloud Storage, Azure Blob) and querying across multiple files with AI-powered answers.
Prerequisites: Set Up Your Cloud Storage Bucket
Before indexing, you need a properly configured cloud storage bucket. Follow these steps to create one with SOC II compliance settings.
AWS S3 Bucket Setup
- Log in to the AWS Console
- Navigate to S3 → Buckets → Create bucket
- Enter a unique bucket name (e.g.,
company-captain-documents) - Select your preferred AWS Region
- Keep Block all public access enabled (recommended)
- Click Create bucket
Enable Object Versioning (SOC II Compliance):
Required for SOC II Compliance: Object versioning maintains a complete audit trail of all document changes, enabling recovery from accidental deletions.
- Click on your newly created bucket
- Navigate to the Properties tab
- Find Bucket Versioning → Click Edit
- Select Enable → Click Save changes
Google Cloud Storage Bucket Setup
- Go to Google Cloud Console
- Navigate to Cloud Storage → Buckets → Create
- Enter a unique bucket name
- Select Standard storage class
- Under Access control, select “Uniform” (recommended)
- Click Create
Enable Object Versioning (SOC II Compliance):
Required for SOC II Compliance: Object versioning maintains a complete audit trail of all document changes.
Via Console:
- Click on your bucket → Configuration tab
- Find Object versioning → Click Edit
- Toggle to Enabled → Click Save
Via command line:
For detailed credential setup, see the Cloud Credentials Guide.
Step 1: Create a Database
Databases are containers for your indexed files. Each database is scoped to your organization and environment.
Step 2: Index Your Cloud Storage
Choose your cloud storage provider:
Option A: Index AWS S3 Bucket
Need AWS credentials? See the Cloud Credentials Guide for step-by-step instructions.
Option B: Index Google Cloud Storage Bucket
Need GCS credentials? See the Cloud Credentials Guide for step-by-step instructions.
Step 3: Monitor Indexing Progress
Step 4: Query Your Indexed Data
Query your database with AI-generated answers:
Or get raw search results (for custom RAG pipelines):
Step 5: Query with Streaming (Optional)
Get real-time responses as they’re generated:
Next Steps: Data Lake Integration
- Full Data Lake Integration Documentation - Complete reference
- Learn about database management
- Explore file-level operations
- Understand re-indexing behavior
- Monitor indexing jobs
Important Concepts
Environment Scoping
API keys are scoped to environments:
- Development (
cap_dev_*) - For testing and development - Staging (
cap_stage_*) - For pre-production testing - Production (
cap_prod_*) - For production use
Databases created with a development key can only be accessed with development keys from the same organization.
Supported File Types
Captain supports 30+ file types including:
Documents: PDF, DOCX, TXT, MD, RTF, ODT Spreadsheets: XLSX, XLS, CSV Presentations: PPTX, PPT Images: JPG, PNG (with OCR) Code: PY, JS, TS, HTML, CSS, PHP, JAVA Data: JSON, XML
See the complete file type list in the Data Lake Integration docs.
Rate Limits
Contact support@runcaptain.com to upgrade.
Comparison: SDK vs HTTP API vs Data Lake
Using the Demo Client
We provide a comprehensive demo client that showcases all Captain features:
The demo client includes examples for:
- Creating databases
- Indexing S3 and GCS buckets
- Querying indexed data
- Processing large context with Captain API
- Streaming responses
Next Steps
For SDK Users:
- Read the Full SDK Documentation
- Explore streaming and advanced features
- Learn about context handling options
- Migrate your existing OpenAI code (Python or JavaScript)
For HTTP API Users:
- Read the Full HTTP API Documentation
- Explore all available endpoints
- Learn about error handling and rate limits
- Implement in your preferred language
For Data Lake Users:
- Read the Data Lake Integration Documentation
- Get your Cloud Storage Credentials
- Index your first bucket
- Start querying your data
Additional Resources:
Getting Help
Need assistance? We’re here to help!
- Email: support@runcaptain.com
- Documentation: docs.runcaptain.com
- Status Page: status.runcaptain.com