Skip to main content

A lightweight API execution layer for LLM agents.

Project description

Codename: Invoke

logo

Invoke is a lightweight framework that connects LLMs with real-world APIs using natural language and structured tool calls.

25-second demo

See the full demo here.

GitHub stars


๐Ÿ“ฆ 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)

Youtube tutorial


๐Ÿ”— 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.
  • ๐Ÿงฉ Flexible integrations via 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 .json or .txt definitions
  • 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", "code": "i"},
  "endpoints": [ /* ... */ ]
}

๐Ÿ” Authorization

  • None: no auth.
  • api_key: api_key (Locally-managed API key)
  • oauth: oauth::i (Invoke-managed OAuth flow)

Override per-endpoint using auth_code. When specified, it overrides the top-level auth.


โœ… Usage Patterns

  • Auto YAML: omit agents to load agents_map.yaml if available.
  • Explicit list: pass aliases, file paths, or mappings.
  • Custom context: override system prompt via context argument.

๐Ÿ“š 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, add your agents.json and follow the prompts.

Need OAuth? See auth.md or override io.get_oauth_code().

โš™๏ธ Ready to deploy? Use Per-User Mode

from invoke_agent.auth import set_current_user

# Set namespace before running queries:
set_current_user('current_user_id')

All OAuthManager calls now use credentials under that user_id namespace, and will never prompt interactively.


โš ๏ธ 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.

License: Apache 2.0 Status: Beta

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

invoke_agent-0.1.2.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

invoke_agent-0.1.2-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file invoke_agent-0.1.2.tar.gz.

File metadata

  • Download URL: invoke_agent-0.1.2.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.18

File hashes

Hashes for invoke_agent-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9408666e756ed2643432f31aacfe38dec523fa7f6d924a4a0eec3bd25c8a0a61
MD5 ade3daef37d585803c4754d3e14d29b0
BLAKE2b-256 fa0fd839a102f11d2ff8248c8c42eb5559978a39899a0f53ab31bdfb0915ac3e

See more details on using hashes here.

File details

Details for the file invoke_agent-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: invoke_agent-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.18

File hashes

Hashes for invoke_agent-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7e4c0883602ebc36b3089d2ee19a3b0cf6c5c93604010cc797b71eb625c720d2
MD5 666442d08b7cc90fd21c78e2e411ef6f
BLAKE2b-256 53bd08ef92eda4ee5b68664547b921c5ef12183e986c51e8357e800d2a175da8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page