Skip to main content

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):

  • CredToolkit returns 3 generic tools: delegate, status, revoke
  • Best for agents that need full credential management

CrewAI integration (cred-crewai):

  • CredTool is 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.

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cred-crewai 2.0.0
File Size Uploaded Provenance Actions
cred_crewai-2.0.0.tar.gz 13.0 kB Without provenance Details for cred_crewai-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cred-crewai 2.0.0
File Interpreter ABI Platform Actions
cred_crewai-2.0.0-py3-none-any.whl Python 3 none any Details for cred_crewai-2.0.0-py3-none-any.whl

Total release size: 23.6 kB

Release files / cred_crewai-2.0.0.tar.gz

Download URL cred_crewai-2.0.0.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
44d7bbacb8268938b5369c411b7f15ecff3d7283dcfb0a70b143f9848f618d79
BLAKE2b-256 checksum
How to use checksums
3c147cf48474f51c73620fd333c1596a4c55ca278d2399339c895b08356c2127
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.0-py3-none-any.whl

Download URL cred_crewai-2.0.0-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7473daa05ca378397336aa27267f051770c4b536bf057176149b83c9a62ec4d1
BLAKE2b-256 checksum
How to use checksums
0a34b798c075977829ae4a43f9ac75461b5518169450b59e1f22d566c4b1739e
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.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page