@pydantic/logfire-ai-sdk-code-mode has 327 recorded weekly downloads on npm, a change of -51.1% over the past 7 days, ranking #2361 of 3,247 tracked listings.
About @pydantic/logfire-ai-sdk-code-mode
Logfire AI SDK Code Mode
Let Vercel AI SDK agents write one Python program that calls their tools, instead of calling them one model turn at a time. The program runs in a Logfire Agent Sandbox, and your tools stay in your Node.js process.
npm install @pydantic/logfire-ai-sdk-code-mode @pydantic/monty@^1.5.0 ai zod
Create a Logfire project API key with the Run code in this project's agent sandboxes permission
(project:execute_agent_sandboxes) and set it as LOGFIRE_API_KEY. The key also selects your data region.
import type { LanguageModel } from 'ai'
import { codeMode } from '@pydantic/logfire-ai-sdk-code-mode'
import { generateText, stepCountIs, tool } from 'ai'
import { z } from 'zod'
const getWeather = tool({
description: 'Get the weather for a city.',
inputSchema: z.object({ city: z.string() }),
outputSchema: z.object({ city: z.string(), forecast: z.string() }),
execute: async ({ city }) => ({ city, forecast: 'Sunny' }),
})
export async function askAgent(model: LanguageModel, prompt: string): Promise<string> {
await using code = codeMode({ tools: { get_weather: getWeather } })
const { text } = await generateText({
model,
prompt,
tools: code.tools,
stopWhen: stepCountIs(10),
})
return text
}
codeMode() turns your tools into typed async Python functions and gives the model one run_code tool to call them
from. Create one codeMode() object per agent run: it is one sandbox session, kept like a REPL for every run_code
call in that run.
See the Agent Sandboxes docs for streaming, approval, tool context, limits, and error handling.
Agent Sandboxes setup and checkout errors end the run instead of reaching the model.
Use codeMode's onError handler for developer-side reporting, and handle thrown errors or rejected streams.
Description from the npm listing.
- logfire
- monty
- sandbox
- agents
- ai-sdk
- code-mode
- python
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (121)Similar npm AI SDKs plugins
All 20 @pydantic/logfire-ai-sdk-code-mode alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/@pydantic/logfire-ai-sdk-code-mode. First seen Dec 1, 2026; last successful collection Dec 1, 2026. See the methodology.