# CrewAI & AutoGen Multi-Agent — API Store Hub

> VI: Phân tầng model theo vai trò trong CrewAI và AutoGen qua https://apistorehub.com/v1: dùng model tiết kiệm cho Researcher/Router và model flagship cho Architect/Reviewer.
> EN: Assign role-specific models in CrewAI and AutoGen via https://apistorehub.com/v1: economical models for workers and flagship models for planning and final review.

- Canonical VI: https://apistorehub.com/vi/tich-hop/crewai-autogen-agents
- Canonical EN: https://apistorehub.com/en/tich-hop/crewai-autogen-agents
- Language: Python
- Runtime: Python 3.10+, crewai, litellm, autogen-agentchat
- Protocol: OpenAI Compatible (/v1/chat/completions)
- Install: `pip install -U crewai`
- Auth Env Var: `API_KEY` (prefix `sk-ash-`)

## Step-by-Step Setup
1. Install `crewai` (or `autogen-agentchat`) and configure `base_url="https://apistorehub.com/v1"`.
2. Prefix model IDs with `openai/` in LiteLLM-backed CrewAI configs so custom catalog names route cleanly.
3. Set strict `max_iter` (3–6) and `max_rpm` limits per agent to cap token burn.
4. Assign `deepseek-v4-pro` to repetitive worker tasks and `claude-sonnet-5-5` to final synthesis.

## Production Code Sample
```
import os
from crewai import Agent, Crew, LLM, Task

planner_llm = LLM(
    model="openai/claude-sonnet-5-5",
    base_url="https://apistorehub.com/v1",
    api_key=os.environ["API_KEY"],
)
worker_llm = LLM(
    model="openai/deepseek-v4-pro",
    base_url="https://apistorehub.com/v1",
    api_key=os.environ["API_KEY"],
)

researcher = Agent(
    role="Market Analyst",
    goal="Collect verified model pricing facts",
    backstory="Data-driven analyst",
    llm=worker_llm,
    max_iter=4,
)
writer = Agent(
    role="Technical Editor",
    goal="Write concise executive report",
    backstory="Senior engineering writer",
    llm=planner_llm,
    max_iter=3,
)
task = Task(description="Compare token vs request billing", expected_output="Markdown summary", agent=researcher)
crew = Crew(agents=[researcher, writer], tasks=[task])
```

## Quick cURL Check
```bash
curl https://apistorehub.com/v1/chat/completions \
  -H "Authorization: Bearer sk-ash-your_key" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-v4-pro","messages":[{"role":"user","content":"List 3 agent guardrails"}]}'
```

## Recommended Models (Live ST Pricing)
| Model | Live Price | Context | Datasheet |
|---|---|---|---|
| `claude-sonnet-5-5` | 7,700 ST / 1M tokens | 1M | https://apistorehub.com/llms/models/claude-sonnet-5-5.md |
| `deepseek-v4-pro` | 3,600 ST / 1M tokens | 1M | https://apistorehub.com/llms/models/deepseek-v4-pro.md |
| `deepseek-v4-flash` | 1,500 ST / 1M tokens | 1M | https://apistorehub.com/llms/models/deepseek-v4-flash.md |

## FAQ
- **How do I point Microsoft AutoGen to API Store Hub?**: Configure `OpenAIChatCompletionClient` with `base_url="https://apistorehub.com/v1"`, your `sk-ash-` key, and any catalog model ID.
- **How can I cut multi-agent token costs by 50-70%?**: Use tiered routing: assign economical models to worker agents and reserve flagship models for final review.
- **Can multiple agents share one API key concurrently?**: Yes. One API key handles high concurrent RPM across all agents while tracking unified usage.
