cred-crewai
CrewAI integration for Cred. OAuth2 credential delegation for AI agents.
Install
pip install cred-crewai
Quick Start
import os
from cred_crewai import CredTool, CredUseTool
from crewai import Agent
from cred import AgentIdentity
# The agent's own did:key identity, created once with cred.generate_agent_identity()
# and persisted with identity.export(); load_agent_identity() stands for your own
# secret store lookup returning that dict.
identity = AgentIdentity.from_export(load_agent_identity())
# Create a pre-configured tool for Google Calendar
google_tool = CredTool(
agent_token=os.environ["CRED_AGENT_TOKEN"],
base_url=os.environ["CRED_BASE_URL"],
user_id="user_123",
service="google",
app_client_id="my_app_client_id",
scopes=["calendar.readonly"],
token_format="handle",
agent_identity=identity,
)
use_tool = CredUseTool(
agent_token=os.environ["CRED_AGENT_TOKEN"],
base_url=os.environ["CRED_BASE_URL"],
agent_identity=identity,
)
# Use with CrewAI agent
agent = Agent(
role="Calendar Manager",
goal="Manage user's calendar",
tools=[google_tool, use_tool],
)
Key Differences from LangChain
LangChain integration (cred-langchain):
CredToolkitreturns 3 generic tools: delegate, status, revoke- Best for agents that need full credential management
CrewAI integration (cred-crewai):
CredToolis pre-configured for a single service- Tool name auto-generated:
cred_google_delegate,cred_github_delegate, etc. - Best for specialized agents (e.g., a "Calendar Manager" agent only needs Google tokens)
Set token_format="handle" to return a brokered delegation id instead of a provider access token. Pair it with CredUseTool when the agent needs to call service APIs through Cred.
agent_identity is required with token_format="handle". The Cred server issues a Delegation Token (a DPoP-bound JWT) to the agent's own key and accepts it only with a DPoP proof signed by that key. The key stays in your process; it is never sent to the model or the server, and it is not a tool argument. The model only sees delegation_id: the token itself is kept in an in-process map (delegation_id to token and expiry), filled by the delegate tool and read by the use tool, so it never appears in tool output. The use tool raises a clear error if no agent_identity is configured or the delegation_id is unknown or expired (call the delegate tool again). In a process that serves more than one user, pass user_id= to the use tool as well: a use tool configured with a user_id refuses delegations issued for any other user. Without it, the user is not checked.
One CredTool per service per agent = clearer intent, smaller decision space for the LLM.
Handling Consent
When a user hasn't connected the service yet, _run() raises ConsentRequiredError.
Catch it and redirect the user to e.consent_url to complete the OAuth flow.
Brokered Server Mode
Point CRED_BASE_URL at your self-hosted @credninja/server deployment and set token_format="handle" when you want the agent to receive delegation ids instead of provider access tokens.
Metadata
Release files for cred-crewai 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cred_crewai-2.0.1.tar.gz | 13.0 kB | Without provenance | Details for cred_crewai-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cred_crewai-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for cred_crewai-2.0.1-py3-none-any.whl |
Total release size: 23.6 kB
Release files / cred_crewai-2.0.1.tar.gz
| Download URL | cred_crewai-2.0.1.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8707bbf244ebfdd76e0736207d5e345ebf5f0f5bebd93bd7d782ffb6b75b6cc2
|
|
BLAKE2b-256 checksum How to use checksums |
19d6d67e2fa88a35524100a1252c05c3de1c2f34cd5ad73bb1b7847294e411ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Release files / cred_crewai-2.0.1-py3-none-any.whl
| Download URL | cred_crewai-2.0.1-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9cfec31ce2f9d76ece2df26a3a2a74707f638020008e9413851f01c71a75abba
|
|
BLAKE2b-256 checksum How to use checksums |
f6de259c680ed0d6bd80ad6243f6991c12c66ef589ea0dd20f44c5ef6ca90f95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Security for cred-crewai 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.