streamable-httpMITupdated 14d ago
The AgentGateway Protocol ā secure, scalable AI agent execution infrastructure.
What can you do with IdentArk Gateway?
identark
The AgentGateway Protocol ā secure, scalable AI agent execution infrastructure.
The problem
When an AI agent can execute code, call APIs, or access files, it runs in a process. That process has an environment. That environment typically contains everything that can cause serious damage: LLM API keys, database credentials, AWS tokens.
The naive solution ā run your agent on the same backend as your REST API ā creates two problems at once:
- Security: The agent can access every secret on the machine.
- Reliability: A memory-hungry agent degrades your API. Redeploying your API kills all running agents.
identark solves both.
How it works
The SDK implements the AgentGateway Protocol ā a clean interface between your agent logic and the outside world. Two implementations ship out of the box:
| Gateway | When to use | Credentials | History |
|---|---|---|---|
DirectGateway |
Local development, CI evals | Your API key | In-memory |
ControlPlaneGateway |
Production on IdentArk | Zero ā none in the agent | Control plane DB |
Your agent code is identical in both environments. The switch is two lines.
Quick start
pip install identark[openai]
import asyncio
from openai import AsyncOpenAI
from identark import DirectGateway, Message, Role
async def main():
gateway = DirectGateway(
llm_client=AsyncOpenAI(), # Your API key ā not in the agent loop
model="gpt-4o",
)
response = await gateway.invoke_llm(
new_messages=[Message(role=Role.USER, content="Hello, IdentArk!")]
)
print(response.message.content)
print(f"Cost: ${response.cost_usd:.6f}")
asyncio.run(main())
Moving to production
Change two lines. Your agent logic is untouched.
# Before (local)
from identark import DirectGateway
gateway = DirectGateway(llm_client=AsyncOpenAI(), model="gpt-4o")
# After (production ā agent holds zero secrets)
from identark import ControlPlaneGateway
gateway = ControlPlaneGateway() # auto-detects env vars inside a IdentArk sandbox
Installation
# Core SDK only
pip install identark
# With OpenAI support
pip install identark[openai]
# With Anthropic support
pip install identark[anthropic]
# With Google Gemini support
pip install identark[gemini]
# With Mistral AI support (EU provider)
pip install identark[mistral]
# All cloud providers
pip install identark[all]
Requirements: Python 3.10+
Using TypeScript? The parity SDK ships as the zero-runtime-dependency
identark npm package, with the same
AgentGateway contract and structured credential sessions.
Data Sovereignty
IdentArk is designed from the ground up to work with any LLM provider, including those that keep your data inside the UK or EU. The AgentGateway Protocol decouples your agent logic from the inference provider ā switching providers requires changing one line.
Run fully local with Ollama (zero data egress)
from openai import AsyncOpenAI
from identark import DirectGateway
gateway = DirectGateway(
llm_client=AsyncOpenAI(
base_url="http://localhost:11434/v1",
api_key="ollama",
),
model="llama3.2",
provider="local", # forces $0 cost tracking; inference stays on your machine
)
Install Ollama: brew install ollama && ollama pull llama3.2 && ollama serve
Use Mistral AI (EU data residency)
from openai import AsyncOpenAI
from identark import DirectGateway
gateway = DirectGateway(
llm_client=AsyncOpenAI(
base_url="https://api.mistral.ai/v1",
api_key="your-mistral-api-key",
),
model="mistral-small-latest", # auto-detected as "mistral" provider
)
Mistral AI is a French company. All inference runs in EU data centres, subject to EU data protection law (GDPR). Use this when UK/EU data governance requirements prohibit sending inference traffic to US-based cloud providers.
See examples/ for complete runnable scripts.
The AgentGateway Protocol
Any class implementing these four async methods is a valid gateway:
class AgentGateway(Protocol):
async def invoke_llm(self, new_messages, tools=None, tool_choice="auto") -> LLMResponse: ...
async def persist_messages(self, messages) -> None: ...
async def request_file_url(self, file_path, method="PUT") -> PresignedURL: ...
async def get_session_cost(self) -> float: ...
Write your agent against the protocol. The implementation ā local or production ā is a runtime detail.
Features
- Zero-secret agents ā
ControlPlaneGatewayholds no API keys, database credentials, or cloud tokens - Stateless by design ā conversation history owned by the gateway, not the agent; kill and restart without data loss
- Framework-agnostic ā works with LangChain, LlamaIndex, raw API calls, or any custom agent framework
- Built-in cost tracking ā every
invoke_llmcall returnscost_usd;get_session_cost()returns the running total - OpenAI + Anthropic ā both providers supported in
DirectGatewayout of the box - MockGateway for testing ā no LLM calls in your test suite; full call recording for assertions
- Full type annotations ā
py.typedmarker; works with mypy strict mode
Testing your agents
from identark.testing import MockGateway
from identark.models import LLMResponse, Message, Role
async def test_my_agent():
mock = MockGateway()
mock.queue_response(LLMResponse(
message=Message(role=Role.ASSISTANT, content="The answer is 42."),
cost_usd=0.001,
model="mock",
finish_reason="stop",
))
result = await my_agent(gateway=mock)
assert mock.invoke_llm_call_count == 1
assert mock.total_messages_sent == 1
Supported providers
| Provider | Data residency | DirectGateway | GeminiGateway | ControlPlaneGateway |
|---|---|---|---|---|
| OpenAI (gpt-4o, gpt-4o-mini, ā¦) | US | ā | ā | ā |
| Anthropic (Claude models) | US | ā | ā | ā |
| Google Gemini | Varies | ā* | ā | Roadmap |
| Mistral AI | Varies | ā | ā | ā |
| Kimi / Moonshot | Varies | ā* | ā | ā |
| Azure OpenAI | Configured Azure region | ā* | ā | ā |
| AWS Bedrock | Configured AWS region | ā | ā | ā |
| OpenRouter | Provider-dependent | ā* | ā | ā |
| Ollama | Local š | ā | ā | Not a hosted route |
| Any OpenAI-compatible endpoint | Varies | ā | ā | ā (custom endpoint) |
*Via an OpenAI-compatible client/base URL. Use GeminiGateway for native Gemini SDK features.
Error handling
from identark.exceptions import CostCapExceededError, RateLimitError, IdentArkError
try:
response = await gateway.invoke_llm(new_messages=[...])
except CostCapExceededError as e:
print(f"Cost cap of ${e.cap_usd} reached. Spent: ${e.consumed_usd}")
except RateLimitError as e:
await asyncio.sleep(e.retry_after_seconds)
except IdentArkError as e:
# Catch-all for any SDK error
raise
Full exception hierarchy: IdentArkError > GatewayError > ControlPlaneError > AuthenticationError | CostCapExceededError | SessionNotFoundError
Architecture
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Your Agent Code ā
ā (depends only on AgentGateway) ā
āāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāā
ā
āāāāāāāāāāāā¼āāāāāāāāāāā
ā AgentGateway ā ā Protocol (interface)
ā Protocol ā
āāāāāāāā¬āāāāāāāāā¬āāāāāāā
ā ā
āāāāāāāāāā¼āā āāāāā¼āāāāāāāāāāāāāāā
ā Direct ā ā ControlPlane ā
ā Gateway ā ā Gateway ā
ā ā ā ā
ā Local / ā ā Production ā
ā Evals ā ā (zero secrets) ā
āāāāāāāāāāāā āāāāāāāāāā¬āāāāāāāāāā
ā HTTP
āāāāāāāāāā¼āāāāāāāāāā
ā IdentArk ā
ā Control Plane ā
ā (holds creds) ā
āāāāāāāāāāāāāāāāāāāā
Community
- Discussions: GitHub Discussions ā ask questions, share ideas
- Issues: GitHub Issues ā bug reports and feature requests
- Live Demo: identark.io/demo ā try IdentArk in your browser
Contributing
Contributions are welcome. Please open an issue before submitting significant changes.
git clone https://github.com/identark/identark.git
cd identark
pip install -e ".[dev]"
pre-commit install
pytest tests/unit/
See CONTRIBUTING.md for full guidelines.
Roadmap
- LangChain adapter (
IdentArkChatModel) - LlamaIndex adapter (
IdentArkLLM) - Streaming support (
invoke_llm_stream) - CrewAI integration
- LangGraph integration (
IdentArkNode,IdentArkStreamNode) - Pluggable inference backends (distributed compute)
-
identark-clifor one-command control plane deployment
License
The IdentArk SDK is licensed under the MIT License ā free for any use, including commercial and closed-source projects. See LICENSE.
The IdentArk control plane (hosted service) is proprietary. The SDK works with any AgentGateway backend, including fully self-hosted ones.
Built on the control plane pattern described in How We Built Secure, Scalable Agent Sandbox Infrastructure.
Install
Add IdentArk Gateway to your client. Pick the one you use.
claude mcp add --transport http identark-gateway https://api.identark.io/v1/mcp/rpccodex mcp add identark-gateway --url https://api.identark.io/v1/mcp/rpc{
"mcpServers": {
"identark-gateway": {
"url": "https://api.identark.io/v1/mcp/rpc"
}
}
}Add to `~/.cursor/mcp.json`, or `.cursor/mcp.json` for a single project.
{
"servers": {
"identark-gateway": {
"type": "http",
"url": "https://api.identark.io/v1/mcp/rpc"
}
}
}Add to `.vscode/mcp.json` in your workspace.
{
"mcpServers": {
"identark-gateway": {
"url": "https://api.identark.io/v1/mcp/rpc"
}
}
}Add to `claude_desktop_config.json`, then restart Claude Desktop.
{
"mcpServers": {
"identark-gateway": {
"serverUrl": "https://api.identark.io/v1/mcp/rpc"
}
}
}Add to `~/.codeium/windsurf/mcp_config.json`.
Score
39 / 100
Incomplete
- Documentation25/25
- Maintenance19/25
- Trust16/20
- Capability0/15
- Install experience12/15
- Documents what it does and how to connect
- Has a resolvable package or endpoint
- Exposes at least one tool, prompt or resource
- README has substantive content
- Includes a code example
- Documents its configuration
- Mentions credentials or security posture
- Last commit 7 days ago
- Has a release history
- Repository is not archived
- Licensed MIT
- Namespace verified in the official MCP registry
- Claimed by its owner
- Published under an organisation
- 0 tool(s) documented
- Provides prompt templates
- Provides resources
- 6 documented install method(s)
- Published to a package registry
- Offers a hosted endpoint ā no local install
Version history
| Versions | Published |
|---|---|
| 0.1.0Latest | Jul 17, 2026 |