3d6418184f
### Changelog
- added support for pulling base images from AWS, Docker, GCP
registries.
- removed unnecessary conversion in build_api.py.
- synced serialize implementation in TypeScript and Python.
- added Cursor Pylance config (side-effect, can delete if unwanted).
### Examples
**TypeScript**
```ts
import { Template } from 'e2b'
// Generic Docker registry
Template().fromRegistry('ubuntu:22.04', {
username: 'jirka',
password: 'password',
})
// AWS ECR registry
Template().fromAWSRegistry('ubuntu:22.04', {
accessKeyId: '123',
secretAccessKey: '456',
region: 'eu-west-1',
})
// GCP GCR registry from file path
Template().fromGCPRegistry('ubuntu:22.04', {
serviceAccountJSON: './service_account.json',
})
// GCP GCR registry from object
Template().fromGCPRegistry('ubuntu:22.04', {
serviceAccountJSON: { project_id: '123', private_key_id: '456' },
})
```
**Python**
```py
from e2b import Template
# Generic Docker registry
Template().from_registry(
image="ubuntu:22.04",
username="jirka",
password="password",
)
# AWS ECR registry
Template().from_aws_registry(
image="ubuntu:22.04",
access_key_id="123",
secret_access_key="456",
region="eu-west-1",
)
# GCP GCR registry from file path
Template().from_gcp_registry(
image="ubuntu:22.04",
service_account_json="./service_account.json",
)
# GCP GCR registry from object
Template().from_gcp_registry(
image="ubuntu:22.04",
service_account_json={"project_id": "123", "private_key_id": "456"},
)
```
What is E2B?
E2B is an open-source infrastructure that allows you to run AI-generated code in secure isolated sandboxes in the cloud. To start and control sandboxes, use our JavaScript SDK or Python SDK.
Run your first Sandbox
1. Install SDK
npm i @e2b/code-interpreter
2. Get your E2B API key
E2B_API_KEY=e2b_***
3. Execute code with code interpreter inside Sandbox
import { Sandbox } from '@e2b/code-interpreter'
const sbx = await Sandbox.create()
await sbx.runCode('x = 1')
const execution = await sbx.runCode('x+=1; x')
console.log(execution.text) // outputs 2
4. Check docs
Visit E2B documentation.
5. E2B cookbook
Visit our Cookbook to get inspired by examples with different LLMs and AI frameworks.
