Python client for the Agent Intent Protocol — declare an intent, let the protocol route it to the optimal AI provider.
Project description
Agent Intent Protocol — Python SDK
Declare what you want. Let the protocol find who does it best.
The Agent Intent Protocol (AIP) decouples an agent's intent
(chat_completion, image_generation, web_search, ...) from the
provider and model that fulfil it. Instead of hard-wiring your code to a
single vendor's API, you declare an intent and the protocol routes it to
the optimal provider — ranked by cost, quality, or latency.
This package is the official Python client. It speaks the AIP wire protocol served by any compliant gateway; by default it targets the JarvisClaw platform.
pip install agent-intent-protocol
Quick start
from agent_intent_protocol import AIPClient, IntentType, OptimizeFor
with AIPClient(api_key="sk-...") as client:
# Resolve an intent to the best-ranked provider.
result = client.resolve(
IntentType.CHAT_COMPLETION,
constraints={"max_price_usd": 0.01},
preferences={"optimize_for": OptimizeFor.COST},
)
best = result.best_match
print(f"{best.provider_id} · {best.model} · score={best.score}")
The API key can also be supplied via the JARVISCLAW_API_KEY
environment variable, in which case AIPClient() needs no arguments.
Resolve, then execute
resolve returns ranked matches so you can inspect price and score
before committing. execute resolves and runs the intent against the
selected provider in one call, proxying the provider response back:
response = client.execute(
IntentType.CHAT_COMPLETION,
payload={"messages": [{"role": "user", "content": "Hello"}]},
preferences={"optimize_for": "quality"},
)
Natural-language intents
Let the gateway interpret a free-form request. It may resolve directly or reply with a clarifying question for a multi-turn exchange:
reply = client.resolve_natural("I need to transcribe an audio file cheaply")
if reply.get("status") == "clarify":
print(reply["message"]) # follow-up question
else:
print(reply["matches"]) # resolved providers
Discovery
# Every intent type the gateway understands.
client.list_intent_types()
# Providers available for a given intent.
client.discover(intent_type=IntentType.IMAGE_GENERATION)
# The full provider catalogue.
client.list_providers()
Intent types
chat_completion, image_generation, video_generation,
text_to_speech, web_search, knowledge_search,
prompt_optimization, document_processing, utility,
code_execution, data_analysis, translation, code_generation.
Errors
All exceptions derive from AIPError:
AIPConnectionError— the request never reached the gateway.AIPAuthError—401/403, missing or invalid API key.AIPPaymentRequiredError—402, x402 payment required.AIPAPIError— any other non-2xx response (status_code,detail,body).
Protocol
The wire format and endpoint contract are defined in the Agent Intent Protocol specification. A Go client is available at agent-intent-protocol-go.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_intent_protocol-0.1.0.tar.gz.
File metadata
- Download URL: agent_intent_protocol-0.1.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6c5dac85975a92e4f5f469b507090de2b7528de0dc57c7f9d78ab4670e9f8b5
|
|
| MD5 |
eba05e4b6dc2b4fb8a4c9a47f077c48c
|
|
| BLAKE2b-256 |
cf1abeb767d6880fddae122382944d9600240d84fc63ff6b5987c7ca2af82d7c
|
File details
Details for the file agent_intent_protocol-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agent_intent_protocol-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df54fd1cd9d4cec12d6519224d0927fa73b478a4cbda224e15ae6d7d004e9ab2
|
|
| MD5 |
d179a3a54c3a8da6e8848fa4809470f9
|
|
| BLAKE2b-256 |
680cbdb0df97dd14c0c202e271dd62087346c4698fba33e4be055a6bd80e921c
|