How to integrate AAIP into existing AI platforms, frameworks, and SDKs.
For transport bindings (gRPC, WebSocket, MCP), see BINDINGS.md.
Most AI agent frameworks use standard HTTP clients. Adding AAIP typically involves:
- Configuring global/default headers
- Wrapping the HTTP client with middleware
| Platform/SDK | Method | Where Visible |
|---|---|---|
| LangChain | Request wrapper config | Server logs |
| AutoGPT | HTTP client config | Server logs |
| Semantic Kernel | HttpClient middleware | Server logs |
| CrewAI | Agent config | Server logs |
| Playwright | Browser context headers | Network tab, server logs |
| Selenium | Proxy or extension | Server logs |
| OpenAI SDK | httpx client config | Server logs |
| Anthropic SDK | httpx client config | Server logs |
from langchain_community.utilities import RequestsWrapper
# v2 format with agent ID and capabilities
headers = {
"AI-Agent": "OpenAI/GPT-5.2 (LangChain; 0.2.0) [aid=langchain-001]",
"AI-Agent-Capabilities": "cap:browse;tools:web_search"
}
requests_wrapper = RequestsWrapper(headers=headers)
# Use in a chain
from langchain_community.tools import RequestsGetTool
tool = RequestsGetTool(requests_wrapper=requests_wrapper)For WebResearchRetriever:
from langchain.retrievers.web_research import WebResearchRetriever
# The retriever uses requests internally
# Patch or configure the underlying session
import requests
original_get = requests.get
def patched_get(*args, **kwargs):
kwargs.setdefault('headers', {})
kwargs['headers']['AI-Agent'] = 'OpenAI/GPT-5.2 (LangChain; 0.1.50)'
return original_get(*args, **kwargs)
requests.get = patched_getConfigure headers in your AutoGPT settings:
# In autogpt startup or config
CUSTOM_HEADERS = {
"AI-Agent": "OpenAI/GPT-5.2 (AutoGPT; 0.5.0) [aid=autogpt-001]",
"AI-Agent-Capabilities": "cap:execute;tools:web_search,code_exec"
}Global patch:
import aiohttp
AI_AGENT = "OpenAI/GPT-5.2 (AutoGPT; 0.5.0) [aid=autogpt-001]"
original_init = aiohttp.ClientSession.__init__
def patched_init(self, *args, **kwargs):
headers = kwargs.get('headers', {})
headers['AI-Agent'] = AI_AGENT
kwargs['headers'] = headers
original_init(self, *args, **kwargs)
aiohttp.ClientSession.__init__ = patched_initUse delegating handlers to add headers to all requests:
// Create a custom delegating handler
public class AIAgentHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken)
{
request.Headers.Add("AI-Agent",
"Azure/openai-GPT-5.2 (SemanticKernel; 1.0) {tools:bing_search}");
return await base.SendAsync(request, cancellationToken);
}
}
// Register with HttpClient
var handler = new AIAgentHandler
{
InnerHandler = new HttpClientHandler()
};
var httpClient = new HttpClient(handler);
// Use with Semantic Kernel
var kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(
"deployment",
"endpoint",
"key",
httpClient: httpClient)
.Build();CrewAI agents can be configured with custom HTTP settings:
from crewai import Agent, Task, Crew
import os
# Set via environment or config
os.environ['AI_AGENT_HEADER'] = 'OpenAI/GPT-5.2 (CrewAI; 0.1.0) {tools:web_search}'
# Or patch the underlying httpx/requests client
import httpx
class AIAgentClient(httpx.Client):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.headers['AI-Agent'] = 'OpenAI/GPT-5.2 (CrewAI; 0.1.0)'
# Use throughout CrewAIconst { chromium } = require('playwright');
const browser = await chromium.launch();
const context = await browser.newContext({
extraHTTPHeaders: {
'AI-Agent': 'Anthropic/claude-4.5 (WebCrawler; 1.0) [Playwright/1.40] {tools:web_search}'
}
});
const page = await context.newPage();
await page.goto('https://example.com');from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
context = browser.new_context(
extra_http_headers={
'AI-Agent': 'OpenAI/GPT-5.2 (Crawler; 2.0) [Playwright]'
}
)
page = context.new_page()
page.goto('https://example.com')Selenium doesn't natively support custom HTTP headers. Options:
Option 1: Browser Extension
// Create an extension that injects headers
// manifest.json
{
"name": "AI-Agent Header",
"version": "1.0",
"manifest_version": 3,
"permissions": ["webRequest", "webRequestBlocking"],
"background": {
"service_worker": "background.js"
}
}
// background.js
chrome.webRequest.onBeforeSendHeaders.addListener(
function(details) {
details.requestHeaders.push({
name: "AI-Agent",
value: "OpenAI/GPT-5.2 (Selenium; 4.10) [Chrome]"
});
return { requestHeaders: details.requestHeaders };
},
{ urls: ["<all_urls>"] },
["blocking", "requestHeaders"]
);Option 2: Proxy (mitmproxy)
# mitmproxy script to inject header
def request(flow):
flow.request.headers["AI-Agent"] = "OpenAI/GPT-5.2 (Selenium; 4.10)"const puppeteer = require('puppeteer');
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setExtraHTTPHeaders({
'AI-Agent': 'OpenAI/GPT-5.2 (Scraper; 1.0) [Puppeteer/22]'
});
await page.goto('https://example.com');The OpenAI SDK doesn't directly expose custom header support for API calls, but you can use httpx:
import httpx
from openai import OpenAI
# Create custom httpx client
http_client = httpx.Client(
headers={"AI-Agent": "OpenAI/GPT-5.2 (MyApp; 1.0)"}
)
# Pass to OpenAI client
client = OpenAI(http_client=http_client)For external browsing requests (not API calls):
# If your agent makes web requests separately from OpenAI calls
import requests
session = requests.Session()
session.headers['AI-Agent'] = 'OpenAI/GPT-5.2 (WebAgent; 1.0) {tools:web_search}'
# Use for all web browsing
response = session.get('https://example.com')Similar approach with httpx:
import httpx
from anthropic import Anthropic
http_client = httpx.Client(
headers={"AI-Agent": "Anthropic/claude-4.5-opus (MyApp; 2.0)"}
)
client = Anthropic(http_client=http_client)import google.generativeai as genai
import httpx
# For web requests made by your agent
class AIAgentTransport(httpx.HTTPTransport):
def handle_request(self, request):
request.headers['AI-Agent'] = 'Google/gemini-3-pro-preview (MyApp; 1.0)'
return super().handle_request(request)For organizations wanting all outbound requests to include the header:
# Inject at application startup
import requests
import httpx
import aiohttp
AI_AGENT_STRING = "YourCompany/internal-model (EnterpriseAgent; 3.0) {tools:internal}"
# Patch requests
_original_request = requests.Session.request
def _patched_request(self, method, url, **kwargs):
kwargs.setdefault('headers', {})
kwargs['headers'].setdefault('AI-Agent', AI_AGENT_STRING)
return _original_request(self, method, url, **kwargs)
requests.Session.request = _patched_request
# Patch httpx (sync)
_original_httpx_request = httpx.Client.request
def _patched_httpx_request(self, method, url, **kwargs):
kwargs.setdefault('headers', {})
kwargs['headers'].setdefault('AI-Agent', AI_AGENT_STRING)
return _original_httpx_request(self, method, url, **kwargs)
httpx.Client.request = _patched_httpx_requestUse a corporate proxy to inject headers for all AI traffic:
# mitmproxy addon
from mitmproxy import http
AI_AGENT = "YourCompany/model (Gateway; 1.0)"
class AddAIAgent:
def request(self, flow: http.HTTPFlow):
flow.request.headers["AI-Agent"] = AI_AGENT
addons = [AddAIAgent()]import os
# Standard environment variable for AI-Agent
AI_AGENT = os.environ.get('AI_AGENT_HEADER',
f"{os.environ.get('AI_VENDOR', 'Unknown')}/{os.environ.get('AI_MODEL', 'unknown')} "
f"({os.environ.get('APP_NAME', 'App')}; {os.environ.get('APP_VERSION', 'unknown')})"
)| Context | How to Verify |
|---|---|
| Server logs | Check request headers in your web server logs |
| Network tab | Browser DevTools → Network → Headers |
| Proxy tools | mitmproxy, Charles, Fiddler |
| httpbin | Send request to https://httpbin.org/headers |
# Quick test with httpbin
curl -H "AI-Agent: OpenAI/GPT-5.2 (Test; 1.0)" https://httpbin.org/headers
# Response will show your header:
# {
# "headers": {
# "Ai-Agent": "OpenAI/GPT-5.2 (Test; 1.0)",
# ...
# }
# }| SDK/Platform | Limitation |
|---|---|
| Selenium | Requires extension or proxy for header injection |
| Some cloud functions | May strip custom headers; verify with your provider |
| API-only SDKs | Header visible only server-side, not in browser network tab |
| Rate-limited APIs | Adding headers won't bypass rate limits |
If you've integrated AAIP into another framework, please submit a PR with your integration guide!