Documentation Index
Fetch the complete documentation index at: https://docs.caistrolabs.com/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Quick Start
from caistro import Caistro, Message
client = Caistro(api_key="YOUR_API_KEY")
response = client.chat(
messages=[
Message(role="user", content="How do I scale Meta ads to $10k/day?")
]
)
print(response.choices[0].message.content)
Configuration
client = Caistro(
api_key="cai_...", # Required
base_url="https://api.caistrolabs.com", # Optional
timeout=30.0 # Optional, in seconds
)
Methods
chat()
Create a chat completion.
from caistro import Caistro, Message
client = Caistro(api_key="YOUR_API_KEY")
response = client.chat(
messages=[
Message(role="system", content="You are a marketing expert."),
Message(role="user", content="How do I improve my CTR?")
],
temperature=0.7,
max_tokens=500,
)
Parameters:
| Name | Type | Required | Description |
|---|
messages | List[Message] | Yes | Conversation history |
model | str | No | Model ID (default: Nous-20B) |
temperature | float | No | Sampling temperature (default: 0.7) |
max_tokens | int | No | Max tokens to generate (default: 512) |
list_models()
List available models.
models = client.list_models()
print(models["data"])
Async Usage
import asyncio
from caistro import AsyncCaistro, Message
async def main():
client = AsyncCaistro(api_key="YOUR_API_KEY")
response = await client.chat(
messages=[
Message(role="user", content="What's the best bidding strategy?")
]
)
print(response.choices[0].message.content)
await client.close()
asyncio.run(main())
Error Handling
from caistro import Caistro, CaistroError, Message
client = Caistro(api_key="YOUR_API_KEY")
try:
response = client.chat(
messages=[Message(role="user", content="Hello")]
)
except CaistroError as e:
print(f"API Error {e.status}: {e.message}")
OpenAI Compatibility
The Caistro API is also OpenAI-compatible. You can use the OpenAI SDK:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_CAISTRO_API_KEY",
base_url="https://api.caistrolabs.com/v1"
)
response = client.chat.completions.create(
model="Nous-20B",
messages=[
{"role": "user", "content": "How do I scale Meta ads?"}
]
)
print(response.choices[0].message.content)