Skip to content
Need an API key for this client? One token for Claude, GPT-6.2, Gemini 4 & DeepSeek V4 — top up via USDT or Alipay

Connect CrewAI to byesu API in Python ​

Key facts: Use from crewai import Agent, Task, Crew, LLM with a single auto group BYESU_API_KEY to mix openai/claude-opus-5-5 (Planner), openai/gpt-6.2-sol (Reviewer), and openai/deepseek-v4-pro (Researcher) over https://byesu.com/v1 — or use anthropic/claude-sonnet-5-5 over https://byesu.com (no /v1) for native 0.1x prompt caching.

CrewAI makes it straightforward to split complex engineering pipelines into specialized roles (Planner, Researcher, Reviewer). Pairing CrewAI with byesu lets each agent run the exact frontier model suited to its job — while drawing from one unified pay-as-you-go balance with itemized per-request telemetry.

Quick configuration

  • OpenAI-compatible multi-vendor route: LLM(model="openai/<model-id>", base_url="https://byesu.com/v1", api_key=...)
  • Anthropic-native route (0.1x cache reads): LLM(model="anthropic/claude-sonnet-5-5", base_url="https://byesu.com", api_key=...) (no /v1)
  • API Key: BYESU_API_KEY="sk-..." created in the default auto group (Sign up & get key)

Prerequisites ​

  1. Issue an sk-... token in the byesu Console under the default auto group (Choosing a Group).
  2. Install CrewAI and export your key:
bash
pip install crewai crewai-tools
export BYESU_API_KEY="sk-your-byesu-token"

Option 1: Heterogeneous Models per Agent Role (One Key via /v1) ​

CrewAI's LLM class delegates provider routing to LiteLLM. Prefixing any console model ID with openai/ instructs CrewAI to send standard /v1/chat/completions calls to https://byesu.com/v1 using your single BYESU_API_KEY:

python
import os
from crewai import Agent, Crew, LLM, Process, Task

BYESU_KEY = os.environ["BYESU_API_KEY"]
BYESU_V1 = "https://byesu.com/v1"

# 1. Flagship architect / planner (99.99% uptime, top multi-step planning)
planner_llm = LLM(
    model="openai/claude-opus-5-5",
    base_url=BYESU_V1,
    api_key=BYESU_KEY,
    timeout=150,
    max_retries=2,
)

# 2. High-throughput researcher / log extractor (zero cache-write surcharge)
researcher_llm = LLM(
    model="openai/deepseek-v4-pro",
    base_url=BYESU_V1,
    api_key=BYESU_KEY,
    timeout=120,
    max_retries=2,
)

# 3. Independent code & security reviewer (deep reasoning verification)
reviewer_llm = LLM(
    model="openai/gpt-6.2-sol",
    base_url=BYESU_V1,
    api_key=BYESU_KEY,
    timeout=180,
    max_retries=2,
)

researcher = Agent(
    role="Distributed Systems Researcher",
    goal="Extract failure modes and retry amplification risks from webhook specs",
    backstory="You audit high-throughput payment and webhook ingestion pipelines.",
    llm=researcher_llm,
    max_iter=10,
)

architect = Agent(
    role="Principal Backend Architect",
    goal="Design an idempotent queue consumer and dead-letter recovery spec",
    backstory="You write concise, production-hardened Go and Python service designs.",
    llm=planner_llm,
    max_iter=12,
)

reviewer = Agent(
    role="Staff Security & Reliability Reviewer",
    goal="Find race conditions, lock-expiry bugs, and missing idempotency keys",
    backstory="You review architecture proposals before production rollout.",
    llm=reviewer_llm,
    max_iter=8,
)

t1 = Task(
    description="List the top 4 retry-storm failure modes in webhook delivery systems.",
    expected_output="Numbered failure matrix with concrete trigger conditions.",
    agent=researcher,
)
t2 = Task(
    description="Propose an idempotent consumer schema and backoff policy addressing those 4 failure modes.",
    expected_output="SQL DDL + worker pseudocode + timeout budget.",
    agent=architect,
)
t3 = Task(
    description="Audit the proposed schema and worker logic for duplicate-execution edge cases.",
    expected_output="Pass/fail checklist with concrete fixes.",
    agent=reviewer,
)

crew = Crew(
    agents=[researcher, architect, reviewer],
    tasks=[t1, t2, t3],
    process=Process.sequential,
)

result = crew.kickoff()
print(result.raw)
print("Token telemetry:", crew.usage_metrics)

Option 2: Native Anthropic Endpoint (0.1x Prompt Caching) ​

When an agent executes 8–15 tool iterations over a large static backstory and tool schema, routing Claude through byesu's native /v1/messages endpoint preserves cache_control discounts down to 0.1x:

Omit /v1 on the anthropic/ route

The Anthropic SDK appends /v1/messages automatically. Pass base_url="https://byesu.com" (without /v1) or export ANTHROPIC_BASE_URL="https://byesu.com".

python
import os
from crewai import LLM

os.environ["ANTHROPIC_BASE_URL"] = "https://byesu.com"
os.environ["ANTHROPIC_API_KEY"] = os.environ["BYESU_API_KEY"]

cached_claude_llm = LLM(
    model="anthropic/claude-sonnet-5-5",
    base_url="https://byesu.com",  # NO /v1 suffix
    api_key=os.environ["BYESU_API_KEY"],
    timeout=120,
)

See Prompt Caching, Explained and Claude 5m vs GPT 30m Cache TTL for keeping agent prefixes byte-deterministic.

Production Engineering Notes & Cost Tracking ​

  • Avoid hardcoded temperature on Claude 5.5 and GPT-6.2: Older CrewAI snippets frequently pass temperature=0.2 or temperature=0.7. Anthropic API 2026-10-21 and OpenAI gpt-6.2-sol reject fixed sampling parameters with HTTP 400 (Claude 400 temperature fix, OpenAI max_tokens fix). Omit temperature on reasoning tiers.
  • Size timeouts from p95, not p50: Reasoning agents (gpt-6.2-sol p95 34.56s, deepseek-v4-pro p95 14.50s) think before emitting tokens. Set timeout=150–180 and max_retries=2 on LLM(...) — see the December 2026 Production Latency & Uptime Report.
  • Itemized per-request cost tracking: Combine crew.usage_metrics (prompt_tokens, cached_prompt_tokens, completion_tokens, successful_requests) in your application logs with the byesu Console → Logs view, which records exact token counts, cache-read multipliers, and pay-as-you-go balance deductions for every sub-agent request. Estimate multi-agent budgets ahead of time in the LLM Token Cost Calculator or generate framework snippets in the Config Generator.

Troubleshooting ​

  • AuthenticationError / missing vendor key: Ensure you prefixed the model ID with openai/ (model="openai/deepseek-v4-pro") and passed api_key + base_url="https://byesu.com/v1" (OpenAI 401 fix).
  • 404 on anthropic/claude-...: Remove /v1 from base_url so it reads "https://byesu.com" (Claude 404 fix).
  • no available channel: Confirm your key is in the auto group (no available channel).

FAQ ​

How do I assign different vendor models to CrewAI agents using a single byesu API key? ​

Instantiate crewai.LLM with model="openai/<console-model-id>", base_url="https://byesu.com/v1", and your BYESU_API_KEY — letting your Planner use claude-opus-5-5, Reviewer use gpt-6.2-sol, and Researcher use deepseek-v4-pro on one key.

Why do CrewAI custom OpenAI-compatible models need the openai/ prefix? ​

CrewAI routes through LiteLLM; the openai/ prefix tells LiteLLM to speak standard OpenAI /v1/chat/completions to https://byesu.com/v1 instead of requiring separate upstream SDK environment variables.

Can CrewAI use byesu's native Anthropic endpoint for 0.1x prompt caching? ​

Yes. Use model="anthropic/claude-sonnet-5-5" with base_url="https://byesu.com" (without /v1) to route through /v1/messages and preserve 0.1x cache-read billing.

How do I prevent HTTP 400 temperature errors and timeouts on reasoning models in CrewAI? ​

Leave temperature unset on Claude 5.5 and GPT-6.2 models, and set timeout=150–180 plus max_retries=2 on LLM(...).

Got a problem? Contact support or join our group.