Daytona

View as MarkdownOpen in Claude

Daytona runs AI-generated code in isolated sandboxes, each one behind an outbound firewall. Sandboxes with full internet access, meaning Tier 3 and Tier 4, reach the You.com APIs with no configuration at all. On Tier 1 and Tier 2, where organization network policy takes precedence over per-sandbox settings, You.com is listed on Daytona’s essential-services allow list. Bring your own API key.

API Hosts

Read this table before you configure anything. The You.com APIs are split across two hosts, and which one you hit decides what a firewall rule has to say.

APIHost
Web Search APIydc-index.io
Contents APIydc-index.io
Answer APIapi.you.com
Research APIapi.you.com
Finance Research APIapi.you.com
MCP serverapi.you.com

Daytona’s essential-services entry covers you.com and *.you.com, so anything on api.you.com is reachable on every tier. ydc-index.io is a separate domain and needs its own allow-list entry. A sandbox that can reach one host but not the other fails in a confusing way: Research and Answer keep working while Web Search and Contents time out.

Confirm reachability from a Tier 1 or Tier 2 sandbox before you build on it. Organization network policy on those tiers cannot be overridden per sandbox, so a blocked host has no per-sandbox workaround. The verification step below returns the status code you need.


Getting Started

1

Install the SDKs

Python
$pip install daytona youdotcom
TypeScript
$npm add @daytona/sdk @youdotcom-oss/sdk

Set DAYTONA_API_KEY in the environment where your control script runs. Get a You.com API key at you.com/platform.

2

Store Your API Key as a Daytona Secret

Do not bake YDC_API_KEY into a snapshot or pass it as a plain sandbox environment variable. A Daytona Secret keeps the plaintext out of the sandbox: the sandbox gets an opaque placeholder, and Daytona’s outbound proxy swaps in the real key only for hosts you name.

create_secret.py
1from daytona import CreateSecretParams, Daytona
2
3daytona = Daytona()
4
5daytona.secret.create(CreateSecretParams(
6 name="youdotcom-api-key",
7 value="<YDC_API_KEY>",
8 description="You.com API key for sandbox agents",
9 hosts=["ydc-index.io", "api.you.com"],
10))
create-secret.ts
1import { Daytona } from "@daytona/sdk";
2
3const daytona = new Daytona();
4
5await daytona.secret.create({
6 name: "youdotcom-api-key",
7 value: process.env.YDC_API_KEY,
8 description: "You.com API key for sandbox agents",
9 hosts: ["ydc-index.io", "api.you.com"],
10});

hosts is the set of destinations the proxy will substitute the real value for, and it needs both entries. ydc-index.io covers the Web Search API and Contents API. api.you.com covers the Answer API, Research API, Finance Research API, and the MCP server. Drop either one and calls to that host go out carrying the placeholder instead of your key, which comes back as a 401.

3

Create a Sandbox and Verify the Path

Map the secret to the environment variable name the You.com SDKs already look for, then confirm the sandbox can actually reach the API before you build anything on top of it.

verify.py
1from daytona import CreateSandboxFromSnapshotParams, Daytona
2
3daytona = Daytona()
4
5sandbox = daytona.create(CreateSandboxFromSnapshotParams(
6 language="python",
7 secrets={"YDC_API_KEY": "youdotcom-api-key"},
8))
9
10response = sandbox.process.exec(
11 'curl -sS -o /dev/null -w "ydc-index.io: %{http_code}\\n" '
12 '-G https://ydc-index.io/v1/search '
13 '-H "X-API-Key: $YDC_API_KEY" --data-urlencode "query=test"; '
14 'curl -sS -o /dev/null -w "api.you.com: %{http_code}\\n" '
15 'https://api.you.com/v1/billing/account_balance '
16 '-H "X-API-Key: $YDC_API_KEY"',
17 timeout=60,
18)
19print(response.result)
verify.ts
1import { Daytona } from "@daytona/sdk";
2
3const daytona = new Daytona();
4
5const sandbox = await daytona.create({
6 language: "typescript",
7 secrets: { YDC_API_KEY: "youdotcom-api-key" },
8});
9
10const response = await sandbox.process.executeCommand(
11 'curl -sS -o /dev/null -w "ydc-index.io: %{http_code}\\n" ' +
12 '-G https://ydc-index.io/v1/search ' +
13 '-H "X-API-Key: $YDC_API_KEY" --data-urlencode "query=test"; ' +
14 'curl -sS -o /dev/null -w "api.you.com: %{http_code}\\n" ' +
15 "https://api.you.com/v1/billing/account_balance " +
16 '-H "X-API-Key: $YDC_API_KEY"',
17 undefined,
18 undefined,
19 60,
20);
21console.log(response.result);

Both lines should print 200. The account balance endpoint is a free call, so it checks reachability and key substitution on api.you.com without spending credits. A 200 is the only proof that matters here: Daytona scrubs the real key out of responses, so an echo service will show you the placeholder whether substitution worked or not.

Daytona’s default command timeout is 10 seconds. Pass an explicit timeout for anything that installs packages or runs a research call.


Usage

Everything in this section runs inside the sandbox. The control script that creates the sandbox stays on your machine.

Search the live web, then pull the full text of the top result.

agent.py
1from youdotcom import You
2from youdotcom.models import ContentsFormats
3
4# Reads YDC_API_KEY from the environment, which Daytona populated
5# with the secret placeholder.
6with You() as you:
7 results = you.search(query="Daytona sandbox release notes", count=5)
8
9 top = results.results.web[0]
10 print(f"{top.title}\n{top.url}\n")
11
12 pages = you.contents(urls=[top.url], formats=[ContentsFormats.MARKDOWN])
13 print(pages[0].markdown[:1000])

Upload it and run it:

1sandbox.fs.upload_file("agent.py", "/home/daytona/agent.py")
2
3result = sandbox.process.exec(
4 "pip install -q youdotcom && python /home/daytona/agent.py",
5 timeout=180,
6)
7print(result.result)

How the Secret Reaches You.com

Daytona substitutes secrets in the outbound proxy rather than inside the sandbox, and the rules are narrow enough to be worth stating outright.

BehaviorWhat it means for You.com calls
HTTPS request headers onlyX-API-Key: $YDC_API_KEY works, and so does Authorization: Bearer against the MCP server
Plain HTTP is never substitutedAlways call https://, never http://, on both hosts
Request bodies pass through unchangedNever put the key in a JSON body. Every You.com endpoint takes it as a header, so this costs you nothing
Query parameters pass through unchangedSame rule. Header auth only
Placeholders must be sent verbatimAnything that transforms the value before sending, such as Base64-encoding it, produces a header the proxy cannot match
Responses are scrubbedIf a service echoes the key back, the proxy rewrites it to the placeholder

Custom Allow Lists

Daytona applies a default network policy based on your organization’s billing tier.

TierOutbound accessYou.com
Tier 1 and Tier 2Restricted, and the restriction cannot be overridden per sandbox. Organization policy wins over domainAllowListListed on the essential-services allow list. Verify both hosts from a sandbox before you depend on either
Tier 3 and Tier 4Full internet by default, with per-sandbox network settings availableReachable by default

On a tier with full internet access, no configuration is needed. The moment you narrow a sandbox with domain_allow_list, though, you replace the permissive default with your own list, and both You.com hosts have to be on it. Use this value:

ydc-index.io,*.ydc-index.io,you.com,*.you.com
Python
1from daytona import CreateSandboxFromSnapshotParams, Daytona
2
3daytona = Daytona()
4
5sandbox = daytona.create(CreateSandboxFromSnapshotParams(
6 domain_allow_list="ydc-index.io,*.ydc-index.io,you.com,*.you.com",
7 secrets={"YDC_API_KEY": "youdotcom-api-key"},
8))
TypeScript
1const sandbox = await daytona.create({
2 domainAllowList: "ydc-index.io,*.ydc-index.io,you.com,*.you.com",
3 secrets: { YDC_API_KEY: "youdotcom-api-key" },
4});

The list is comma-separated, domains only, with *. wildcards and a maximum of 20 entries. domainAllowList, networkAllowList, and networkBlockAll are mutually exclusive, and setting more than one non-empty value returns a 400.

you.com and *.you.com cover everything on api.you.com, which is the Answer API, Research API, Finance Research API, and the MCP server. They do not cover the Web Search API or the Contents API, both of which are served from ydc-index.io. Include both pairs unless you are certain the sandbox will never call Web Search or Contents.


Resources