LangChain with 6bee.ai
LangChain’s ChatOpenAI works with any OpenAI-compatible API. Give it the 6bee.ai base URL, your key and a model ID.
Before you start
Create an account with a verified email address, add prepaid balance, then create a key on the console's API keys page. Keep the key secret.
Model IDs are listed in the console and returned by GET https://api.6bee.ai/v1/models. Replace <model id> with one of them.
Python
from langchain_openai import ChatOpenAI # pip install langchain-openai
llm = ChatOpenAI(model="<model id>", base_url="https://api.6bee.ai/v1",
api_key="<your key>", max_tokens=2048)
print(llm.invoke("Explain this stack trace").content) JavaScript
import { ChatOpenAI } from '@langchain/openai'; // npm install @langchain/openai
const llm = new ChatOpenAI({
model: '<model id>', apiKey: process.env.SIXBEE_API_KEY, maxTokens: 2048,
configuration: { baseURL: 'https://api.6bee.ai/v1' },
});
console.log((await llm.invoke('Explain this stack trace')).content); Agents and batches
An account runs 2 requests at a time. LangChain’s batch calls and multi-agent graphs run many in parallel by default, so cap them:
answers = llm.batch(prompts, config={"max_concurrency": 2}) - Input tokens
- 1,000,000 uncached tokens per rolling minute. Cache hits don’t count.
- Requests
- 60 per minute.
- Concurrency
- 2 requests at a time.
Tool calling works on models that implement it. Behaviour differs between models, so test the one you plan to use.
Troubleshooting
- HTTP 401
- The key is missing or wrong. Copy it again from the console, without spaces or quotes.
- Model not found
- The model ID does not match. List the valid IDs with
GET /v1/modelsor check the console. - HTTP 429
- You are over a per-account limit (requests, input tokens or concurrency). The
Retry-Afterheader says how long to wait. - HTTP 400 on long sessions
- The request no longer fits the model’s context window. Compact or clear the conversation, or switch to a model with a larger window.
- Request rejected for balance
- Each request first reserves its input plus
max_tokensof output. Top up, or lowermax_tokens.