CrewAI
Use AICredits with CrewAI agents by setting the OpenAI base URL, API key, and model for crews and flows.
Use this page with an AI assistant
Opens a new chat with this docs URL and the correct AICredits base URLs.
CrewAI is a Python framework for orchestrating multi-agent workflows. AICredits works with CrewAI through its OpenAI-compatible LLM configuration.
Environment Setup
Set the OpenAI-compatible environment variables:
OPENAI_API_KEY=sk-your-aicredits-key
OPENAI_BASE_URL=https://api.aicredits.in/v1
MODEL=openai/gpt-4o-miniDirect Code
Configure an AICredits-backed LLM in Python:
from crewai import Agent, Crew, LLM, Task
llm = LLM(
model="openai/gpt-4o-mini",
api_key="sk-your-aicredits-key",
base_url="https://api.aicredits.in/v1",
temperature=0.3,
)
researcher = Agent(
role="Researcher",
goal="Answer questions concisely",
backstory="You are a practical research assistant.",
llm=llm,
)
task = Task(
description='Reply with "AICredits via CrewAI" and nothing else.',
expected_output="The exact confirmation phrase.",
agent=researcher,
)
crew = Crew(agents=[researcher], tasks=[task])
print(crew.kickoff())YAML Agents
In an agents.yaml file, use the AICredits model ID:
researcher:
role: Researcher
goal: Find practical answers
backstory: You summarize information clearly.
llm: openai/gpt-4o-miniFor crews with multiple agents, use smaller models for routing and extraction, then reserve larger models for final synthesis.
Verify
Run one kickoff and check Dashboard -> Usage for the request.
Troubleshooting
CrewAI uses OpenAI directly - Confirm OPENAI_BASE_URL is set to https://api.aicredits.in/v1.
Model not found - Use an exact model ID from Models.
Crew loops are expensive - Add iteration limits and use budget-capped AICredits keys for agent experiments.