Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pip install 'stirrup[all]' # or: uv add 'stirrup[all]'

# Individual extras
pip install 'stirrup[litellm]' # or: uv add 'stirrup[litellm]'
pip install 'stirrup[anyllm]' # or: uv add 'stirrup[anyllm]'
pip install 'stirrup[docker]' # or: uv add 'stirrup[docker]'
pip install 'stirrup[e2b]' # or: uv add 'stirrup[e2b]'
pip install 'stirrup[mcp]' # or: uv add 'stirrup[mcp]'
Expand Down Expand Up @@ -164,6 +165,27 @@ agent = Agent(

See [LiteLLM Example](https://stirrup.artificialanalysis.ai/examples/#litellm-multi-provider-support) or [Deepseek Example](https://stirrup.artificialanalysis.ai/examples/#openai-compatible-apis-deepseek-vllm-ollama) for complete examples.

### any-llm (Anthropic, Google, etc.)

```python
# Ensure any-llm is added with: pip install 'stirrup[anyllm]' # or: uv add 'stirrup[anyllm]'
# Create any-llm client for Anthropic Claude
# See https://mozilla-ai.github.io/any-llm/providers/ for all supported providers
client = AnyLLMClient(
model_slug="anthropic/claude-opus-5",
max_tokens=8_192,
context_window_tokens=1_000_000,
)

# Pass client to Agent - model info comes from client.model_slug
agent = Agent(
client=client,
name="claude_agent",
)
```

See [any-llm Example](https://stirrup.artificialanalysis.ai/examples/#any-llm-multi-provider-support) or [Deepseek Example](https://stirrup.artificialanalysis.ai/examples/#openai-compatible-apis-deepseek-vllm-ollama) for complete examples.

## Default Tools

When you create an `Agent` without specifying tools, it uses `default_tools()`:
Expand Down
12 changes: 12 additions & 0 deletions docs/api/clients/anyllm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# any-llm Client

!!! note "Optional Dependency"
any-llm is an optional dependency. Install with:
```bash
pip install stirrup[anyllm] # or: uv add stirrup[anyllm]
```

`max_tokens` limits provider output. `context_window_tokens` (required) separately
tells the agent when conversation history should be summarized.

::: stirrup.clients.anyllm_client
19 changes: 19 additions & 0 deletions docs/concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,25 @@ Use `LiteLLMClient` for Anthropic, Google, and other providers via [LiteLLM](htt
!!! note "LiteLLM Installation"
Requires `pip install stirrup[litellm]` (or: `uv add stirrup[litellm]`)

### AnyLLMClient

Use `AnyLLMClient` for Anthropic, Google, and other providers via [any-llm](https://mozilla-ai.github.io/any-llm/providers/):

```python
--8<-- "examples/anyllm_example.py:client"
```

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `model_slug` | `str` | required | Provider/model string (e.g., `"anthropic/claude-opus-5"`) |
| `max_tokens` | `int` | `64_000` | Maximum provider response/output tokens |
| `context_window_tokens` | `int` | required | Context capacity for summarization |
| `reasoning_effort` | `str \| None` | `None` | For reasoning models (e.g. GPT-5.6) |
| `kwargs` | `dict \| None` | `None` | Additional provider-specific arguments |

!!! note "any-llm Installation"
Requires `pip install stirrup[anyllm]` (or: `uv add stirrup[anyllm]`)

### Creating Your Own Client

Implement the `LLMClient` protocol to create a custom client:
Expand Down
11 changes: 11 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ Use LiteLLM to connect to non-OpenAI providers like Anthropic Claude, Google Gem
!!! note
Requires `pip install stirrup[litellm]` (or: `uv add stirrup[litellm]`) and the appropriate API key for your chosen provider (e.g., `ANTHROPIC_API_KEY` for Claude).

## any-llm Multi-Provider Support

Use any-llm to connect to non-OpenAI providers like Anthropic Claude, Google Gemini, and many others.

```python
--8<-- "examples/anyllm_example.py"
```

!!! note
Requires `pip install stirrup[anyllm]` (or: `uv add stirrup[anyllm]`) and the appropriate API key for your chosen provider (e.g., `ANTHROPIC_API_KEY` for Claude).

## Custom Finish Tool

Define structured output with a custom finish tool:
Expand Down
3 changes: 2 additions & 1 deletion docs/extending/clients.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ This guide covers implementing custom LLM clients for Stirrup.

## Built-in Clients

Stirrup provides three built-in clients:
Stirrup provides four built-in clients:

| Client | API | Best For |
|--------|-----|----------|
| [`ChatCompletionsClient`](../api/clients/chat_completions.md) | OpenAI Chat Completions | OpenAI, OpenRouter, vLLM, Ollama, and other OpenAI-compatible APIs |
| [`OpenResponsesClient`](../api/clients/open_responses.md) | OpenAI Responses API | Providers implementing the newer Responses API format |
| [`LiteLLMClient`](../api/clients/litellm.md) | LiteLLM | Multi-provider support (Anthropic, Google, Azure, etc.) |
| [`AnyLLMClient`](../api/clients/anyllm.md) | any-llm | Multi-provider support (Anthropic, Google, etc.) |

## LLMClient Protocol

Expand Down
1 change: 1 addition & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pip install 'stirrup[all]' # or: uv add 'stirrup[all]'
| Extra | Description |
|-------|-------------|
| `litellm` | Multi-provider support via LiteLLM (Anthropic, Google, etc.) |
| `anyllm` | Multi-provider support via any-llm (Anthropic, Google, etc.) |
| `docker` | Docker-based code execution |
| `e2b` | E2B cloud sandboxes |
| `mcp` | MCP server support |
Expand Down
9 changes: 9 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pip install 'stirrup[all]' # or: uv add 'stirrup[all]'

# Individual extras
pip install 'stirrup[litellm]' # or: uv add 'stirrup[litellm]'
pip install 'stirrup[anyllm]' # or: uv add 'stirrup[anyllm]'
pip install 'stirrup[docker]' # or: uv add 'stirrup[docker]'
pip install 'stirrup[e2b]' # or: uv add 'stirrup[e2b]'
pip install 'stirrup[mcp]' # or: uv add 'stirrup[mcp]'
Expand Down Expand Up @@ -73,6 +74,14 @@ For non-OpenAI providers, change the base URL of the `ChatCompletionsClient`, us

See [LiteLLM Example](examples.md#litellm-multi-provider-support) or [Deepseek Example](examples.md#openai-compatible-apis) for complete examples.

### any-llm (Anthropic, Google, etc.)

```python
--8<-- "examples/anyllm_example.py:client"
```

See [any-llm Example](examples.md#any-llm-multi-provider-support) or [Deepseek Example](examples.md#openai-compatible-apis) for complete examples.

## Default Tools

When you create an `Agent` without specifying tools, it uses `default_tools()`:
Expand Down
43 changes: 43 additions & 0 deletions examples/anyllm_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Example: Using Agent with any-llm for multi-provider support.

Demonstrates using any-llm to connect to non-OpenAI providers like Anthropic Claude,
Google Gemini, etc. For any-llm, create the client directly and pass it to the Agent.

Requires:
- uv pip install stirrup[anyllm]
- ANTHROPIC_API_KEY environment variable (for this example)
"""

import asyncio

from stirrup import Agent
from stirrup.clients.anyllm_client import AnyLLMClient


async def main() -> None:
"""Run an agent using Anthropic Claude via any-llm."""
# --8<-- [start:client]
# Create any-llm client for Anthropic Claude
# See https://mozilla-ai.github.io/any-llm/providers/ for all supported providers
client = AnyLLMClient(
model_slug="anthropic/claude-opus-5",
max_tokens=8_192,
context_window_tokens=1_000_000,
)

# Pass client to Agent - model info comes from client.model_slug
agent = Agent(
client=client,
name="claude_agent",
)
# --8<-- [end:client]

async with agent.session(output_dir="./output/anyllm_example") as session:
await session.run(
"What has the temperature been in the last 3 days in San Francisco? "
"Provide a brief summary and output a pdf file with the summary and a graph."
)


if __name__ == "__main__":
asyncio.run(main())
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ nav:
- ChatCompletions: api/clients/chat_completions.md
- OpenResponses: api/clients/open_responses.md
- LiteLLM: api/clients/litellm.md
- any-llm: api/clients/anyllm.md
- Tools:
- Overview: api/tools/index.md
- Web Tools: api/tools/web.md
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ dependencies = [

[project.optional-dependencies]
litellm = ["litellm>=1.79.3"]
anyllm = ["any-llm-sdk[gemini]>=1.27.0,<1.29.0"]
e2b = ["e2b-code-interpreter>=2.3.0"]
e2b-throttle = ["stirrup[e2b]", "aiolimiter>=1.1.0"]
docker = ["docker>=7.0.0", "python-dotenv>=1.0.0"]
mcp = ["mcp>=1.9.0"]
browser = ["browser-use>=0.11.3"]
slack = ["slack-bolt>=1.20.0"]
all = ["stirrup[litellm,e2b,e2b-throttle,docker,mcp,browser,slack]"]
all = ["stirrup[litellm,anyllm,e2b,e2b-throttle,docker,mcp,browser,slack]"]

[project.urls]
Homepage = "https://github.com/ArtificialAnalysis/Stirrup"
Expand Down
3 changes: 3 additions & 0 deletions src/stirrup/clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

For multi-provider support via LiteLLM, install the litellm extra:
pip install stirrup[litellm]

For multi-provider support via any-llm, install the anyllm extra:
pip install stirrup[anyllm]
"""

from stirrup.clients.chat_completions_client import ChatCompletionsClient
Expand Down
Loading