A lightweight API execution layer for LLM agents.
Project description
Invoke Documentation
Invoke is a lightweight framework that connects LLMs with real-world APIs using natural language and structured tool calls.
๐ฆ Installation
pip install invoke-agent
๐ Quickstart
from langchain_openai import ChatOpenAI
from invoke_agent.agent import InvokeAgent
# Use GPT-4.1 for best results
llm = ChatOpenAI(model="gpt-4.1")
# Pass built-in aliases, file paths, or URLs; or omit to auto-load agents_map.yaml
invoke = InvokeAgent(llm, agents=["google-calendar", "./custom/weather.json"])
while True:
user_input = input("๐ You: ").strip()
if user_input.lower() in ["exit", "quit"]:
break
response = invoke.chat(user_input)
print("\n๐ค", response)
๐ LangChain Integration
For full control you can integrate with LangChain directly:
from invoke_agent.core import api_executor
from invoke_agent.context import build_context
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate
# Define your LLM
llm = ChatOpenAI(model="gpt-4.1")
# Build a prompt template
prompt = ChatPromptTemplate.from_messages([
("placeholder", "{chat_history}"),
("human", "{input}"),
("placeholder", "{agent_scratchpad}")
])
# Create the agent
agent = create_tool_calling_agent(llm=llm, tools=[api_executor], prompt=prompt)
executor = AgentExecutor(agent=agent, tools=[api_executor], verbose=True)
# Invoke with context containing your integrations
result = executor.invoke({
"input": "What's the weather in Paris?",
"chat_history": build_context(agents=["open-meteo"])
})
print(result["output"])
๐ ๏ธ Features
- ๐ Access any HTTP API using natural language.
- ๐ Automatic OAuth and API key management.
- ๐ Supports both OpenAI and Claude-style function calls.
- ๐ง Persistent chat memory for multi-turn conversations.
- ๐งฉ Flexible integrations via YAML, JSON, or TXT definitions.
- ๐ค Works with any LangChain-compatible LLM (we recommend GPT-4.1).
๐ Defining Integrations
You can specify integrations via the agents parameter:
- Built-in aliases: e.g.
"google-calendar","open-meteo" - File paths or URLs: direct references to
.jsonor.txtdefinitions - Explicit mappings:
{ "my-calendar": "./calendar.json" }
# All valid:
invoke = InvokeAgent(llm, agents=[
"google-calendar",
"https://example.com/my_agents.txt",
{"custom-weather": "./agents/weather.json"}
])
# Or omit to load './agents_map.yaml' if present:
invoke = InvokeAgent(llm)
๐ agents.json / agents.txt
- agents.json is a structured schema defining tool names, URLs, methods, parameters, headers, and auth.
- agents.txt is the Markdown-rendered version produced by
render_agents_txt(), used in the system prompt.
{
"agent": "gmail",
"label": "Gmail API",
"base_url": "https://www.googleapis.com",
"auth": {"type": "oauth", "format": "Bearer", "code": "i"},
"endpoints": [ /* ... */ ]
}
๐ Authorization
- None: no auth.
- query:
query::api_key - header:
header::Authorization - body:
body::token(injects credential into JSON body) - oauth:
oauth::Bearer::i(Invoke-managed OAuth flow) - machine:
machine::client(M2M credentials)
Override per-endpoint using auth_code. When specified, it overrides the top-level auth.
โ Usage Patterns
- Auto YAML: omit
agentsto loadagents_map.yamlif available. - Explicit list: pass aliases, file paths, or mappings.
- Custom context: override system prompt via
contextargument.
๐ Invoke Documentation
Hereโs how the pieces fit together:
โโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ auth.py โโโโโโโโโถ๏ธโ core.py โ
โโโโโโโโโโโ โโโโโโโโฌโโโโโโโ
โ
โผ
โโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โcontext.py โโโโโโโถ๏ธโ agent.py โ
โโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โฒ
โ
โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โcompile.py โโ๏ธโโโโโค agents.json โ
โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
Each file plays a specific role:
| Module | Description |
|---|---|
agent.md |
How to instantiate and use the InvokeAgent |
core.md |
Core logic for API execution |
io.md |
Interface for prompts, logs, and OAuth code entry |
context.md |
Builds runtime context using agents.json and templates |
compile.md |
Converts agents.json into readable agents.txt |
auth.md |
Guide to adding custom OAuth logic (e.g. Flask server) |
agents_json.md |
Full schema spec for agents.json, with examples |
๐ Getting Started
Jump right in with example notebooks to run your first agent with OpenAI, Claude, or Mistral.
Want to integrate a new API? Head to agents_json.md.
Need OAuth? See oauth.md or override io.get_oauth_code().
โ ๏ธ BETA SOFTWARE โ NOT FOR PRODUCTION
This project is in active development and provided as-is, for testing and evaluation purposes only. Use at your own risk. The author is not liable for any bugs, breakage, data loss, security issues, or cosmic anomalies that may arise from using this code.
Project details
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 invoke_agent-0.1.0.tar.gz.
File metadata
- Download URL: invoke_agent-0.1.0.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b53081dc98d63d0bdf240698096516d896d8314ab52e355e6947ceae13af48a
|
|
| MD5 |
a5ba87963071d421cf9733d7b5847661
|
|
| BLAKE2b-256 |
3e878e789e1e572840ced75ca2a34572f46cc0b939b5632c42717a1546ed59ee
|
File details
Details for the file invoke_agent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: invoke_agent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49710e823d183e3f47871141ae7250c9e2089f5210e99dbe5a7a23e6cec41455
|
|
| MD5 |
298ac43dce1defaff268b8c459dbf69c
|
|
| BLAKE2b-256 |
3af1f516f4f40ab56665d391bddead481bd80a2c01050ce775e7f16f8688d7e7
|