Skip to content
Merged
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
3 changes: 2 additions & 1 deletion python/ai-data-analyst/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
DAYTONA_API_KEY=
ANTHROPIC_API_KEY=
OPENAI_API_KEY=
FIREWORKS_AI_API_KEY=
MISTRAL_API_KEY=
DEEPSEEK_API_KEY=
OPENROUTER_API_KEY=
OPENROUTER_API_KEY=
2 changes: 2 additions & 0 deletions python/ai-data-analyst/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ To run this example, you need to set the following environment variables:

- `ANTHROPIC_API_KEY`: Required if using Anthropic models (default)
- `OPENAI_API_KEY`: Required if using OpenAI models
- `FIREWORKS_AI_API_KEY`: Required if using Fireworks AI models
- `MISTRAL_API_KEY`: Required if using Mistral AI models
- `DEEPSEEK_API_KEY`: Required if using DeepSeek models
- `OPENROUTER_API_KEY`: Required if using OpenRouter models
Expand Down Expand Up @@ -99,6 +100,7 @@ The coding model is used for high accuracy code generation, and the summary mode
Other suggested models include:

- `openai/gpt-5.1`
- `fireworks_ai/accounts/fireworks/models/kimi-k2p6`
- `mistral/mistral-large-latest`
- `deepseek/deepseek-chat`
- `openrouter/moonshotai/kimi-k2`
Expand Down
7 changes: 6 additions & 1 deletion python/langchain/data-analysis/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
DAYTONA_API_KEY=
ANTHROPIC_API_KEY=
# Model in "provider:model" format; defaults to the Anthropic model below.
# MODEL=anthropic:claude-sonnet-4-5-20250929
# Set the API key matching your chosen provider:
ANTHROPIC_API_KEY=
# FIREWORKS_API_KEY=
# OPENAI_API_KEY=
17 changes: 16 additions & 1 deletion python/langchain/data-analysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ In this example, the agent analyzes a vehicle valuations dataset to understand h
To run this example, you need to set the following environment variables:

- `DAYTONA_API_KEY`: Required for access to Daytona sandboxes. Get it from [Daytona Dashboard](https://app.daytona.io/dashboard/keys)
- `ANTHROPIC_API_KEY`: Required for Claude AI model access. Get it from [Anthropic Console](https://console.anthropic.com/)
- `MODEL` (optional): The model in `provider:model` format. Defaults to `anthropic:claude-sonnet-4-5-20250929`
- The API key matching your chosen provider:
- `ANTHROPIC_API_KEY`: Required if using Anthropic models (default)
- `FIREWORKS_API_KEY`: Required if using Fireworks AI models
- `OPENAI_API_KEY`: Required if using OpenAI models

See the `.env.example` file for the exact structure. Copy `.env.example` to `.env` and fill in your API keys before running.

Expand Down Expand Up @@ -70,6 +74,17 @@ Before proceeding, complete the following steps:

## Configuration

- **LLM Provider:** The model is set via the `MODEL` environment variable in `provider:model` format and works with any [provider supported by LangChain](https://docs.langchain.com/oss/python/integrations/chat). Install the provider's integration package and set its API key. For example, to use [Fireworks AI](https://fireworks.ai/):

```bash
pip install -U langchain-fireworks
```

```env
MODEL=fireworks:accounts/fireworks/models/kimi-k2p6
FIREWORKS_API_KEY=your-fireworks-api-key
```

- **Analysis Prompt:** The main prompt is configured in the `agent.invoke()` call inside `data_analysis.py`. You can modify this prompt to analyze different aspects of the data or try different visualization types.

- **Dataset Description:** When uploading the dataset, provide a clear description of the columns and data cleaning instructions to help the agent understand how to process the data.
Expand Down
9 changes: 7 additions & 2 deletions python/langchain/data-analysis/data_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"""LangChain data analysis example using Daytona sandboxes."""

import base64
import os

from dotenv import load_dotenv
from langchain.agents import create_agent # pylint: disable=import-error
from langchain_anthropic import ChatAnthropic # pylint: disable=import-error
from langchain.chat_models import init_chat_model # pylint: disable=import-error

# pylint: disable=import-error
from langchain_daytona_data_analysis import DaytonaDataAnalysisTool
Expand All @@ -16,7 +17,11 @@

load_dotenv()

model = ChatAnthropic(model_name="claude-sonnet-4-5-20250929", temperature=0, timeout=None, max_retries=2, stop=None)
# "provider:model" string, e.g. "fireworks:accounts/fireworks/models/kimi-k2p6".
# See the README for supported providers and their API keys.
MODEL = os.environ.get("MODEL", "anthropic:claude-sonnet-4-5-20250929")

model = init_chat_model(MODEL, temperature=0, max_retries=2)


def process_data_analysis_result(result: ExecutionArtifacts):
Expand Down
7 changes: 6 additions & 1 deletion python/langgraph/plan-and-execute-data-agent/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Get your API key from https://app.daytona.io/dashboard/keys
DAYTONA_API_KEY=
# Model in "provider:model" format; defaults to the Anthropic model below.
# MODEL=anthropic:claude-opus-4-6
# Set the API key matching your chosen provider:
# Get your Anthropic API key from https://console.anthropic.com/
ANTHROPIC_API_KEY=
ANTHROPIC_API_KEY=
# FIREWORKS_API_KEY=
# OPENAI_API_KEY=
19 changes: 17 additions & 2 deletions python/langgraph/plan-and-execute-data-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ In this example, the agent profiles the maintenance health of the public [`langc
## Environment Variables

- `DAYTONA_API_KEY`: Required for access to Daytona sandboxes. Get it from [Daytona Dashboard](https://app.daytona.io/dashboard/keys)
- `ANTHROPIC_API_KEY`: Required for Claude model access. Get it from [Anthropic Console](https://console.anthropic.com/)
- `MODEL` (optional): The model in `provider:model` format. Defaults to `anthropic:claude-opus-4-6`
- The API key matching your chosen provider:
- `ANTHROPIC_API_KEY`: Required if using Anthropic models (default)
- `FIREWORKS_API_KEY`: Required if using Fireworks AI models
- `OPENAI_API_KEY`: Required if using OpenAI models

Copy `.env.example` to `.env` and fill in your API keys before running.

Expand All @@ -41,7 +45,7 @@ Copy `.env.example` to `.env` and fill in your API keys before running.
2. Install dependencies:

```bash
pip install -U langgraph langchain-core langchain-anthropic daytona pydantic python-dotenv
pip install -U langgraph langchain langchain-anthropic daytona pydantic python-dotenv
```

3. Set your API keys in `.env`:
Expand All @@ -51,6 +55,17 @@ Copy `.env.example` to `.env` and fill in your API keys before running.
ANTHROPIC_API_KEY=your_anthropic_api_key
```

The model is set via the `MODEL` environment variable in `provider:model` format and works with any [provider supported by LangChain](https://docs.langchain.com/oss/python/integrations/chat). Install the provider's integration package and set its API key. For example, to use [Fireworks AI](https://fireworks.ai/):

```bash
pip install -U langchain-fireworks
```

```bash
MODEL=fireworks:accounts/fireworks/models/kimi-k2p6
FIREWORKS_API_KEY=your_fireworks_api_key
```

4. Run the example:

```bash
Expand Down
18 changes: 9 additions & 9 deletions python/langgraph/plan-and-execute-data-agent/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

"""Plan-and-execute LangGraph agent that ETLs GitHub data into a Daytona-sandboxed SQLite."""

import os
import re
from typing import TypedDict

from dotenv import load_dotenv # pylint: disable=import-error
from langchain_anthropic import ChatAnthropic # pylint: disable=import-error
from langchain.chat_models import init_chat_model # pylint: disable=import-error
from langchain_core.language_models import BaseChatModel # pylint: disable=import-error
from langchain_core.messages import HumanMessage, SystemMessage # pylint: disable=import-error
from langgraph.graph import END, START, StateGraph # pylint: disable=import-error
from pydantic import BaseModel, Field # pylint: disable=import-error
Expand All @@ -16,6 +18,10 @@

load_dotenv()

# "provider:model" string, e.g. "fireworks:accounts/fireworks/models/kimi-k2p6".
# See the README for supported providers and their API keys.
MODEL = os.environ.get("MODEL", "anthropic:claude-opus-4-6")

USER_REQUEST = """Profile the maintenance health of the public GitHub repository `langchain-ai/langgraph`.

Fetch the 100 most recently updated issues from
Expand Down Expand Up @@ -108,7 +114,7 @@ def extract_code(text: str) -> str:
return match.group(1).strip() if match else text.strip()


def build_graph(model: ChatAnthropic):
def build_graph(model: BaseChatModel):
"""Wire the 6-node plan-and-execute state graph."""
plan_llm = model.with_structured_output(Plan)

Expand Down Expand Up @@ -248,13 +254,7 @@ def cleanup(state: AgentState) -> dict:


def main() -> None:
model = ChatAnthropic(
model_name="claude-opus-4-6",
temperature=0,
timeout=120,
max_retries=2,
stop=None,
)
model = init_chat_model(MODEL, temperature=0, timeout=120, max_retries=2)
app = build_graph(model)

print("=" * 60)
Expand Down
2 changes: 2 additions & 0 deletions typescript/mastra/coding-agent/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
# openai/gpt-4o-mini
# anthropic/claude-sonnet-4-5-20250929
# google/gemini-2.5-pro
# fireworks-ai/accounts/fireworks/models/kimi-k2p6
# groq/llama-3.3-70b-versatile
MODEL=openai/gpt-4o-mini

# API Keys (only needed for your chosen provider)
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
GOOGLE_GENERATIVE_AI_API_KEY=
FIREWORKS_API_KEY=
GROQ_API_KEY=
CEREBRAS_API_KEY=
MISTRAL_API_KEY=
Expand Down
1 change: 1 addition & 0 deletions typescript/mastra/coding-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ This template supports any AI model provider through Mastra's model router. You
- **OpenAI**: `openai/gpt-4o-mini`, `openai/gpt-4o`
- **Anthropic**: `anthropic/claude-sonnet-4-5-20250929`, `anthropic/claude-haiku-4-5-20250929`
- **Google**: `google/gemini-2.5-pro`, `google/gemini-2.0-flash-exp`
- **Fireworks AI**: `fireworks-ai/accounts/fireworks/models/kimi-k2p6`, `fireworks-ai/accounts/fireworks/models/glm-5p2`
- **Groq**: `groq/llama-3.3-70b-versatile`, `groq/llama-3.1-8b-instant`
- **Cerebras**: `cerebras/llama-3.3-70b`
- **Mistral**: `mistral/mistral-medium-2508`
Expand Down
31 changes: 27 additions & 4 deletions typescript/vercel-ai-sdk/multi-language-benchmark-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,19 @@ Worth noticing in the transcript:
- **Step 5 batches parallel tool calls.** Both `downloadFile` calls go out in the same turn and the Vercel AI SDK runs them concurrently, so the chart and the report ship to local disk at the same time rather than back-to-back.
- **Steps 1, 2, 3 all use `runCode`** to execute Python, TypeScript, and Python (matplotlib) in turn. No `runCommand` was needed for the TypeScript step because `runCode` handles `ts-node` invocation internally. The exact step count and tool mix will vary run to run; some runs may use `runCommand` if the agent decides to `pip install` an extra package or inspect the filesystem before plotting.

## Switching to OpenAI
## Switching providers

Install [`@ai-sdk/openai`](https://www.npmjs.com/package/@ai-sdk/openai) and replace the provider import in `src/index.ts`:
The default is Anthropic Claude Sonnet 4.6, but any AI SDK provider that supports tool calling works. Install the provider package and replace the provider import in `src/index.ts`.

> [!NOTE]
> The provider package major version must match this guide's `ai` v6: use `@ai-sdk/openai@3` / `@ai-sdk/fireworks@2`. If you upgrade `ai` to v7, install the latest provider versions instead.

### OpenAI

Install [`@ai-sdk/openai`](https://www.npmjs.com/package/@ai-sdk/openai):

```bash
npm install @ai-sdk/openai
npm install @ai-sdk/openai@3
```

```typescript
Expand All @@ -149,4 +156,20 @@ import { openai } from '@ai-sdk/openai'
const MODEL = openai('gpt-4o')
```

Set `OPENAI_API_KEY` in `.env` instead of `ANTHROPIC_API_KEY`. The default is Anthropic Claude Sonnet 4.6, but any AI SDK provider that supports tool calling works.
Set `OPENAI_API_KEY` in `.env` instead of `ANTHROPIC_API_KEY`.

### Fireworks AI

Install [`@ai-sdk/fireworks`](https://www.npmjs.com/package/@ai-sdk/fireworks):

```bash
npm install @ai-sdk/fireworks@2
```

```typescript
import { fireworks } from '@ai-sdk/fireworks'
// ...
const MODEL = fireworks('accounts/fireworks/models/kimi-k2p6')
```

Set `FIREWORKS_API_KEY` in `.env` instead of `ANTHROPIC_API_KEY`.
Loading