Chat Completions
OpenAI-compatible chat completions endpoint for Captain
Usage with OpenAI SDK:
```python
from openai import OpenAI
client = OpenAI(
base_url="https://api.runcaptain.com/v1",
api_key="your-captain-api-key"
)
# Option 1: Context in captain.context parameter
response = client.chat.completions.create(
model="captain-voyager-latest",
messages=[{"role": "user", "content": "How many errors are in the logs?"}],
stream=True,
extra_body={"captain": {"context": "...your 100k token log file..."}}
)
# Option 2: Context in system message (for smaller contexts)
response = client.chat.completions.create(
model="captain-voyager-latest",
messages=[
{"role": "system", "content": "Context: ...your data..."},
{"role": "user", "content": "Analyze this data"}
],
stream=True
)
```
Response
Successful Response