Files
librechat.ai/content/docs/features/code_interpreter.mdx
Marco Beretta 4656b0116a feat: Migrate to Fumadocs, overhaul UI, and improve docs navigation (#500)
* feat: enhance accessibility and improve component structure across various files

* feat: enhance components with TypeScript typings and improve documentation

- Added TypeScript interface for Screenshot component props.
- Updated button component documentation for clarity.
- Removed unnecessary console log in ContainerScroll component.
- Added descriptive comments for FloatingDock and utility functions.
- Improved CSP headers in next.config.mjs for security.
- Cleaned up package.json by removing unused dependencies.
- Refactored _app.tsx to use AppProps for type safety.
- Updated meta configuration by removing hidden display property.
- Added API documentation comments for GitHub stats and subscription endpoints.
- Enhanced error handling in subscription API.
- Updated Tailwind CSS configuration with detailed comments.
- Cleaned up style.css by organizing and refining styles.
- Updated tsconfig.json to include TypeScript files for API routes.
- Added comments to Subscriber model and dbConnect utility for clarity.

* feat: add aria-labels to HeroLinks for improved accessibility

* feat: replace Twitter icon with X and add new X icon component

* chore: update code structure for better readability and maintenance

* chore: update .gitignore to include additional AI assistant files and Claude Flow generated files

* feat: replace sidebar emojis with Lucide icons, fix duplicate titles, and clean up codebase

- Add icon resolver (lib/icons.tsx) with 73 Lucide React icons mapped to string IDs
- Wire icon resolver into Fumadocs loader for automatic sidebar icon rendering
- Update all 19 meta.json files to use icon field instead of emoji prefixes
- Add icon frontmatter to all 162 MDX documentation pages
- Deduplicate adjacent sidebar icons (e.g. Search/ListFilter, Brain/Bookmark)
- Remove duplicate H1 headings from 154 MDX files (DocsTitle renders frontmatter)
- Add frontmatter to 33 files that were missing it
- Shorten overly long titles (agents, mcp, url_query)
- Rewrite /docs/local cards from old Nextra syntax to Fumadocs Card components
- Remove all emojis from Get Started and Features index pages
- Collapse sidebar folders by default (defaultOpenLevel: 0)
- Delete temporary debugging scripts, test specs, and screenshot artifacts
- Fix eslint errors in mdx-components, nextra-shims, tailwind config, and error page
- Update .gitignore to exclude test/debug artifacts

* feat: enhance accessibility and improve UI components

- Added aria-hidden attributes to social media icons in FooterMenu for better accessibility.
- Updated FooterMenu to use <footer> element for semantic HTML.
- Improved Carousel component by adding aria-labels to navigation buttons for better screen reader support.
- Modified OptionTable to use a unique key for each row to prevent rendering issues.
- Enhanced CredentialsGeneratorBox with aria-labels for input fields and buttons to improve accessibility.
- Updated documentation to remove unnecessary links and improve clarity in various sections.
- Fixed iframe attributes in documentation for better compatibility and accessibility.
- Adjusted CSS variable for muted foreground color to improve contrast.
- Updated package.json and pnpm-lock.yaml for dependency management and optimization.

* feat: update FileComponent and FolderComponent to include new props for enhanced functionality

* Add new AI provider icons and update documentation

- Introduced new SVG icons for AI providers: TogetherAI, TrueFoundry, VLLM, Vultr, and XAI.
- Updated existing AI endpoint documentation to reflect new icon names and improve clarity.
- Replaced generic \Plug\ icons with specific provider icons for Anyscale, APIpie, Cloudflare, Cohere, Databricks, DeepSeek, Fireworks, Groq, Helicone, HuggingFace, LiteLLM, Mistral, MLX, Moonshot, NeuroChain, Ollama, OpenRouter, Perplexity, Portkey, ShuttleAI, and TrueFoundry.
- Enhanced the icon resolution logic to include new icons in the icon registry.

* feat: add DocsHub and QuickStartHub components for enhanced documentation navigation

* feat: implement FeaturesHub component for enhanced feature navigation and update ViewOptions for improved links

* feat: add fresh-build script for streamlined project setup and development

* fix: update ESLint configuration and improve type handling in components

- Added 'next.config.mjs' to ESLint ignore list.
- Refactored version assignment in ChangelogPage for better type safety.
- Removed unnecessary type casting in Author components for cleaner code.
- Simplified BlogHeader component by removing redundant type assertions.
- Added eslint-disable comments for unused variables in CardCompat and Nextra shims.

* fix: update ViewOptions link for LibreChat to remove unnecessary submit parameter

* feat: enhance HomePage layout and improve GitHub star display

- Integrated HomeLayout component for better page structure.
- Updated HeroSection to improve the presentation of GitHub stars with a new layout and styling.
- Adjusted link attributes for better accessibility and user experience.

* refactor: simplify title for Model Context Protocol (MCP) documentation

- Changed the title from "Model Context Protocol (MCP)" to "MCP" for brevity.
- Updated the description to clarify how LibreChat utilizes MCP for integration with external tools and services.

* feat: enhance navigation styling and update HomeLayout props

- Added a new background style for the navigation bar with a blur effect.
- Updated HomeLayout component to include a transparent navigation mode for improved visual integration.

* refactor: deprecate plugins in favor of agents and update related documentation

- Removed references to plugins across various files, including the FeaturesHub and documentation.
- Updated navigation redirects to point to agents instead of plugins.
- Deleted the plugins documentation file to streamline content and reduce confusion.

* feat: update demo images for improved visual representation

---------

Co-authored-by: Danny Avila <danny@librechat.ai>
2026-02-18 10:44:38 -05:00

149 lines
6.2 KiB
Plaintext

---
title: Code Interpreter API
icon: SquareTerminal
description: Execute code securely and manage files seamlessly with LibreChat's Code Interpreter API
---
## Introduction
LibreChat's Code Interpreter API provides a secure and hassle-free way to execute code and manage files through a simple API interface. Whether you're using it through LibreChat's Agents or integrating it directly into your applications, the API offers a powerful sandbox environment for running code in multiple programming languages.
<video
controls
width="100%"
style={{ marginTop: '2rem', marginBottom: '2rem' }}
>
<source src="https://firebasestorage.googleapis.com/v0/b/superb-reporter-407417.appspot.com/o/Sequence%2001.mp4?alt=media&token=595b0716-12f1-4516-be93-c7004a85b540" type="video/mp4" />
Your browser does not support the video tag.
</video>
## Subscription
**Access to this feature requires an [API subscription, get started here](https://code.librechat.ai/pricing).**
## Getting Started
1. Visit [code.librechat.ai](https://code.librechat.ai/pricing) to get your API key
2. Integrate the API into your application or use it through LibreChat
3. Start executing code and generating files securely
## Key Features
### Supported Languages
Execute code in multiple programming languages:
- Python, Node.js (JS/TS), Go, C/C++, Java, PHP, Rust, Fortran, Rscript
### Seamless File Handling
- Upload files for processing
- Download generated outputs
- Secure file management
- Session-based file organization
### Security & Convenience
- Secure sandboxed execution environment
- No local setup required
- No server deployment needed
- No configuration management
## Using the API
### In LibreChat
The API has first-class support in LibreChat through two main methods:
1. **[AI Agents](/docs/features/agents#code-interpreter)**: Enable Code Interpreter in your agent's configuration to allow it to execute code and process files automatically.
2. **Manual Execution**: Use the "Run Code" button in code blocks within the chat interface, as shown here:
![Code Interpreter in LibreChat](/images/agents/run_code.png)
### Set up API key
- **Per-user setup:** input your API key in LibreChat when prompted (using the above methods)
- **Global setup:** use `LIBRECHAT_CODE_API_KEY` environment variable in the .env file of your project (provides access to all users)
### Direct API Integration
The Code Interpreter API can be integrated into any application using a simple API key authentication:
1. Get your API key from [code.librechat.ai](https://code.librechat.ai/pricing)
2. Include the API key in your requests using the `x-api-key` header
### Enterprise
The enterprise plan requires use of the `LIBRECHAT_CODE_BASEURL` environment variable to correspond with the self-hosted instance of the API, along with any generated API keys from the dashboard, used the same way as mentioned above.
## Core Functionality
### Code Execution
- Run code snippets in supported languages
- Receive stdout/stderr output
- Get execution statistics (memory usage, CPU time)
- Handle program arguments
- Access execution status and results
### File Operations
- Upload input files
- Download generated outputs
- List available files
- Delete unnecessary files
- Manage file sessions
### Limitations
- Code cannot access the network
- Only 10 files can be generated per run
- Execution limits vary by plan:
- **Hobby**:
- 256 MB RAM per execution
- 25 MB per file upload
- 750 requests per month
- **Enthusiast**:
- 512 MB RAM per execution
- 50 MB per file upload
- 3,000 requests per month
- **Pro**:
- 512 MB RAM per execution
- 150 MB per file upload
- 7,000 requests per month
- The [Enterprise Plan](https://code.librechat.ai/pricing) provides custom limits and features
## Use Cases
- **Code Testing**: Test code snippets in multiple languages
- **File Processing**: Transform and analyze files programmatically
- **AI Applications**: Execute AI-generated code securely
- **Development Tools**: Build interactive coding environments
- **Objective Logic**: Verify code logic and correctness, improving AI models
## Why a Paid API?
While LibreChat remains free and open source under the MIT license, the Code Interpreter API is offered as a paid service for several key reasons:
1. **Project Sustainability**: Subscribing to an API plan provides direct support to the project's development, even more effectively than [GitHub Sponsors](https://github.com/sponsors/danny-avila). Your subscription helps ensure LibreChat's continued growth and improvement.
2. **Technical Considerations**: Including code execution capabilities in the core project would add significant complexity and hardware requirements that not all users need. The API service eliminates these concerns while maintaining a lightweight core application.
3. **Managed Service Benefits**:
- No complex configuration
- Immediate availability
- Regular updates and maintenance
- Professional support
- Secure, sandboxed environment
4. **Intellectual Property Protection**: The Code Interpreter's architecture represents significant innovation in secure, scalable sandbox technology. While similar solutions exist, they often lack the comprehensive security measures and scalability features that make this implementation unique. Keeping this component as a closed-source API helps protect these innovations and ensures the service maintains its high security and performance standards.
Even if you only use code execution occasionally, subscribing helps support LibreChat's development while enhancing your experience with professional-grade features. It's a win-win that keeps the core project free while offering optional advanced capabilities for those who need them.
---
## Conclusion
The Code Interpreter API provides a secure, convenient way to execute code and manage files without the hassle of setting up and maintaining execution environments. Whether you're using it through LibreChat's Agents or integrating it directly into your applications, it offers a robust solution for code execution needs.
For detailed technical specifications and API reference, please visit our [API Documentation](https://code.librechat.ai/docs).
#LibreChat #CodeExecution #API #Development