supported_features
include tools in GET /v1/models. For confidential-only calls, use
https://tee.redpill.ai/v1 with an is_tee: true model.
export REDPILL_AI_API_KEY="YOUR_API_KEY"
- CrewAI
- PydanticAI
- OpenAI Agents SDK
CrewAI uses LiteLLM internally. Prefix the RedPill model id with
CrewAI LLM connections
openai/ so LiteLLM selects its
OpenAI-compatible adapter; RedPill receives z-ai/glm-5.2.pip install crewai
import os
from crewai import Agent, Crew, LLM, Process, Task
llm = LLM(
model="openai/z-ai/glm-5.2",
base_url="https://api.redpill.ai/v1",
api_key=os.environ["REDPILL_AI_API_KEY"],
temperature=0,
)
reviewer = Agent(
role="Code reviewer",
goal="Identify correctness and security risks",
backstory="A senior engineer who reports concrete findings.",
llm=llm,
max_iter=3,
)
review = Task(
description="Review the supplied change summary: {change_summary}",
expected_output="A prioritized list of findings with suggested fixes.",
agent=reviewer,
)
crew = Crew(agents=[reviewer], tasks=[review], process=Process.sequential)
result = crew.kickoff(inputs={"change_summary": "Adds token refresh without retry limits."})
print(result)
| Symptom | Check |
|---|---|
| LiteLLM cannot select a provider | Keep the openai/ prefix before the RedPill model id. |
| Crew loops too long | Reduce max_iter and add task-level execution limits. |
PydanticAI exposes an OpenAI-compatible provider directly. Use
PydanticAI OpenAI models
OpenAIChatModel for the Chat
Completions endpoint.pip install pydantic-ai
import os
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai import OpenAIProvider
from pydantic_ai.usage import UsageLimits
model = OpenAIChatModel(
"z-ai/glm-5.2",
provider=OpenAIProvider(
base_url="https://api.redpill.ai/v1",
api_key=os.environ["REDPILL_AI_API_KEY"],
),
)
agent = Agent(model, system_prompt="Be concise and state uncertainty.")
@agent.tool_plain
def deployment_status(service: str) -> str:
"""Return a sample deployment status."""
return f"{service}: healthy"
result = agent.run_sync(
"Check the gateway deployment status.",
usage_limits=UsageLimits(request_limit=3, tool_calls_limit=1),
)
print(result.output)
| Symptom | Check |
|---|---|
| Provider initialization fails | Use OpenAIProvider with the /v1 base URL. |
| Tool calls exceed expectations | Lower request_limit and tool_calls_limit. |
The SDK uses the Responses API by default. Wrap a custom
OpenAI Agents SDK models
AsyncOpenAI client in
OpenAIChatCompletionsModel. Tracing is disabled because the default exporter needs an OpenAI
platform key; configure another trace processor if you need tracing.pip install openai-agents
import os
from agents import (
Agent,
OpenAIChatCompletionsModel,
Runner,
function_tool,
set_tracing_disabled,
)
from openai import AsyncOpenAI
set_tracing_disabled(True)
client = AsyncOpenAI(
base_url="https://api.redpill.ai/v1",
api_key=os.environ["REDPILL_AI_API_KEY"],
)
model = OpenAIChatCompletionsModel(model="z-ai/glm-5.2", openai_client=client)
@function_tool
def deployment_status(service: str) -> str:
"""Return a sample deployment status."""
return f"{service}: healthy"
agent = Agent(
name="Operations assistant",
instructions="Use the tool to check deployment status.",
model=model,
tools=[deployment_status],
)
result = Runner.run_sync(agent, "Check the gateway deployment status.", max_turns=3)
print(result.final_output)
| Symptom | Check |
|---|---|
| SDK calls the wrong API shape | Wrap the client with OpenAIChatCompletionsModel. |
| Default tracing reports errors | Disable tracing or configure a compatible trace processor. |