LAP integrates with popular agent frameworks. Each integration converts LAP specs into the framework's native tool/document format.
LAP provides a LangChain-compatible DocumentLoader that loads LAP files as LangChain Document objects.
pip install lapsh[langchain]from lap.middleware import LAPDocLoader
# Load a LAP file — one Document per endpoint
loader = LAPDocLoader("output/stripe-charges.lap")
docs = loader.load()
print(f"Loaded {len(docs)} endpoint documents")
for doc in docs:
print(f"--- {doc.metadata['method']} {doc.metadata['path']} ---")
print(doc.page_content[:200])Each Document contains:
page_content: The endpoint signature, parameters, and response schemametadata:source,api,method,path
For injecting the entire API spec as a single document:
full_docs = loader.load_full()
print(f"Full context: {len(full_docs[0].page_content)} chars")from langchain.vectorstores import FAISS
from langchain.embeddings import OpenAIEmbeddings
# Index all endpoints
loader = LAPDocLoader("output/github-core.lap")
docs = loader.load()
vectorstore = FAISS.from_documents(docs, OpenAIEmbeddings())
# Query
results = vectorstore.similarity_search("create a repository")
# Returns the POST /repos endpoint documentContext Hub equips coding agents with curated, versioned documentation. The LAP registry is a supported Context Hub source - agents can discover and fetch LAP specs directly.
Add the LAP registry to your config.yaml:
sources:
- name: default
url: https://cdn.aichub.org/v1
- name: lap
url: https://registry.lap.sh/chub# Search for API docs via Context Hub
chub search stripe --source lap
# Fetch a spec
chub get stripe --source lapAgents using Context Hub will automatically discover LAP specs alongside other documentation sources.
For frameworks not listed above, use the Python or TypeScript SDK directly:
from lap import LAPClient
client = LAPClient()
doc = client.load("output/stripe-charges.lap")
# Get full context string for LLM injection
context = doc.to_context(lean=True)
print(f"Context: {doc.token_count(lean=True)} tokens")
# Query specific endpoints
ep = doc.get_endpoint("POST", "/v1/charges")
print(f"Required: {[p.name for p in ep.required_params]}")
print(f"Optional: {[p.name for p in ep.optional_params]}")import { LAPClient, toContext } from '@lap-platform/lapsh';
const client = new LAPClient();
const spec = client.loadFile('output/stripe-charges.lap');
// Full context
const context = toContext(spec, { lean: true });
// Filter specific endpoints
const filtered = toContext(spec, {
lean: true,
endpoints: ['POST /v1/charges', 'GET /v1/charges']
});const spec = await client.fromRegistry('http://localhost:8420', 'stripe-charges');
const context = toContext(spec);