{"id":39479252,"url":"https://github.com/runloopai/api-client-ts","last_synced_at":"2026-02-27T22:29:56.757Z","repository":{"id":246123730,"uuid":"817924319","full_name":"runloopai/api-client-ts","owner":"runloopai","description":"Typescript API to access the Runloop platform","archived":false,"fork":false,"pushed_at":"2026-02-13T18:56:06.000Z","size":35916,"stargazers_count":28,"open_issues_count":5,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-14T01:52:29.005Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://runloopai.github.io/api-client-ts/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/runloopai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-06-20T18:16:33.000Z","updated_at":"2026-02-13T18:55:33.000Z","dependencies_parsed_at":"2026-01-22T03:08:40.121Z","dependency_job_id":null,"html_url":"https://github.com/runloopai/api-client-ts","commit_stats":null,"previous_names":["runloopai/api-client-ts"],"tags_count":114,"template":false,"template_full_name":null,"purl":"pkg:github/runloopai/api-client-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runloopai%2Fapi-client-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runloopai%2Fapi-client-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runloopai%2Fapi-client-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runloopai%2Fapi-client-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/runloopai","download_url":"https://codeload.github.com/runloopai/api-client-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runloopai%2Fapi-client-ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29627807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T18:02:07.722Z","status":"ssl_error","status_checked_at":"2026-02-19T18:01:46.144Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-18T05:01:12.572Z","updated_at":"2026-02-27T22:29:56.751Z","avatar_url":"https://github.com/runloopai.png","language":"TypeScript","funding_links":[],"categories":["[Runloop](https://runloop.ai)"],"sub_categories":[],"readme":"# Runloop Node API Library\n\n[![NPM version](https://img.shields.io/npm/v/@runloop/api-client.svg)](https://npmjs.org/package/@runloop/api-client) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@runloop/api-client)\n\nThis library provides convenient access to the Runloop SDK \u0026 REST API from server-side TypeScript or JavaScript.\n\nThe **RunloopSDK** is the recommended, modern way to interact with the Runloop API. It provides high-level object-oriented interfaces for common operations while maintaining full access to the underlying REST API through the `.api` property.\n\n## Installation\n\n```sh\nnpm install @runloop/api-client\n```\n\n## Quickstart\n\nHere's a complete example that demonstrates the core SDK functionality:\n\n```typescript\nimport { RunloopSDK } from '@runloop/api-client';\n\nconst sdk = new RunloopSDK({\n  bearerToken: process.env.RUNLOOP_API_KEY, // This is the default and can be omitted\n});\n\n// Create a new devbox and wait for it to be ready\nconst devbox = await sdk.devbox.create();\n\n// Execute a synchronous command\nconst result = await devbox.cmd.exec('echo \"Hello, World!\"');\nconsole.log('Output:', await result.stdout()); // \"Hello, World!\"\nconsole.log('Exit code:', result.exitCode); // 0\n\n// Start a long-running HTTP server asynchronously\nconst serverExec = await devbox.cmd.execAsync('npx http-server -p 8080');\nconsole.log(`Started server with execution ID: ${serverExec.executionId}`);\n\n// Check server status\nconst state = await serverExec.getState();\nconsole.log('Server status:', state.status); // \"running\"\n\n// Later... kill the server when done\nawait serverExec.kill();\n\nawait devbox.shutdown();\n```\n\n## Core Concepts\n\n### Runloop SDK\n\nThe main SDK class that provides access to all Runloop functionality construct view the [RunloopSDK documentation](https://runloopai.github.io/api-client-ts/stable/classes/RunloopSDK.html) to see specific capabilities.\n\n### Available Resources\n\nThe SDK provides object-oriented interfaces for all major Runloop resources:\n\n- **[`runloop.devbox`](https://runloopai.github.io/api-client-ts/stable/classes/DevboxOps.html)** - Devbox management (create, list, execute commands, file operations)\n- **[`runloop.blueprint`](https://runloopai.github.io/api-client-ts/stable/classes/BlueprintOps.html)** - Blueprint management (create, list, build blueprints)\n- **[`runloop.snapshot`](https://runloopai.github.io/api-client-ts/stable/classes/SnapshotOps.html)** - Snapshot management (list disk snapshots)\n- **[`runloop.storageObject`](https://runloopai.github.io/api-client-ts/stable/classes/StorageObjectOps.html)** - Storage object management (upload, download, list objects)\n- **[`runloop.agent`](https://runloopai.github.io/api-client-ts/stable/classes/AgentOps.html)** - Agent management (create, list agents from npm/pip/git)\n- **[`runloop.scenario`](https://runloopai.github.io/api-client-ts/stable/classes/ScenarioOps.html)** - Scenario management (list scenarios, start runs)\n- **[`runloop.scorer`](https://runloopai.github.io/api-client-ts/stable/classes/ScorerOps.html)** - Scorer management (create, list, update)\n- **[`runloop.api`](https://runloopai.github.io/api-client-ts/stable/classes/Runloop.html)** - Direct access to the REST API client\n\n## TypeScript Support\n\nThe SDK is fully typed with comprehensive TypeScript definitions:\n\n### Blueprints\n\nBlueprints define reusable devbox configurations. Create blueprints via `runloop.blueprint.create()` and access build logs with `blueprint.logs()`:\n\n```typescript\nconst blueprint = await runloop.blueprint.create({\n  name: 'my-blueprint',\n  dockerfile: 'FROM ubuntu:22.04\\nRUN apt-get update',\n});\n\n// Get build logs\nconst logs = await blueprint.logs();\nconsole.log(logs.logs);\n\n// Create a devbox from the blueprint\nconst devbox = await blueprint.createDevbox({ name: 'my-devbox' });\n```\n\n### Scorers\n\nScorers are custom scoring functions used to evaluate scenario outputs. Create scorers via `runloop.scorer.create()`, then update them with the returned `Scorer` instance:\n\n```typescript\nimport { RunloopSDK } from '@runloop/api-client';\n\nconst runloop = new RunloopSDK();\n\nconst scorer = await runloop.scorer.create({\n  type: 'my_scorer',\n  bash_script: 'echo \"1.0\"',\n});\n\nawait scorer.update({ bash_script: 'echo \"0.5\"' });\n```\n\n### Scenarios\n\nScenarios define tasks with a well defined starting environment, task evaluation scorer and an optional reference solution.. Use `runloop.scenario.fromId()` to get a scenario, then `scenario.run()` to start a run with your agent mounted:\n\n```typescript\nconst scenario = runloop.scenario.fromId('scn_123');\nconst run = await scenario.run({\n  run_name: 'my-run',\n  runProfile: {\n    mounts: [\n      {\n        type: 'agent_mount',\n        agent_id: 'agt_123',\n        agent_path: '/home/user/agent',\n      },\n    ],\n  },\n});\nawait run.devbox.cmd.exec('python /home/user/agent/main.py');\nawait run.scoreAndComplete();\n```\n\n### Benchmarks\n\nBenchmarks are collections of scenarios for evaluating AI agents. Access via `runloop.api.benchmarks`:\n\n```typescript\nconst benchmarks = await runloop.api.benchmarks.listPublic();\nconst definitions = await runloop.api.benchmarks.definitions('benchmark_id');\n```\n\n## Migration from API Client\n\nIf you're currently using the legacy API, migration is straightforward:\n\nAll of the runloop client methods `runloop.secrets` has moved to `runloopSDK.api.secrets`. Updating all references to this will move to the new sdk client.\n\n```typescript\n// Before (Legacy api client)\nimport Runloop from '@runloop/api-client';\nconst runloop = new Runloop();\nconst secretResult = await runloop.secrets.create({ ... });\n\n\n// After (SDK)\nimport { RunloopSDK } from '@runloop/api-client';\nconst runloop  = new RunloopSDK();\nconst secretResult = await runloop.api.secrets.create({ ... });\n```\n\nOnce you've migrated your existing code to the new SDK client you can optionally go through and move from the API paradime to the object oriented SDK.\n\n```ts\n// Before (Legacy api client)\nimport Runloop from '@runloop/api-client';\nconst runloop = new Runloop()\n\nconst devboxResult = await runloop.devboxes.createAndAwaitRunning()\n\nawait runloop.devboxes.executeAndAwaitCompletion(devboxResult.id, { command: \"touch example.txt\" })\n\nconst snapshotResult = await runloop.devbox.snapshotDisk()\nawait runloop.devboxes.snapshotDisk(devboxResult.id)\nawait runloop.snapshots.awaitCompleted(snapshotResult.id)\nrunloop.devbox.create({ snapshot_id: snapshotResult.id})\n...\nawait runloop.devbox.shutdown(devboxResult.id)\n\n// After (SDK)\nimport { RunloopSDK } from '@runloop/api-client';\nconst runloop  = new RunloopSDK();\n\nconst devbox = await runloop.devbox.create();\nawait devbox.cmd.exec(\"touch example.txt\");\nconst snapshot = await devbox.snapshotDisk();\nawait snapshot.createDevbox();\n...\nawait devbox.shutdown();\n\n```\n\n## File write\n\n// You can also pass a `fetch` `Response`:\nawait client.devboxes.uploadFile('id', {\npath: 'path',\nfile: await fetch('https://somesite/file'),\n});\n\n// Finally, if none of the above are convenient, you can use our `toFile` helper:\nawait client.devboxes.uploadFile('id', {\npath: 'path',\nfile: await toFile(Buffer.from('my bytes'), 'file'),\n});\nawait client.devboxes.uploadFile('id', {\npath: 'path',\nfile: await toFile(new Uint8Array([0, 1, 2]), 'file'),\n});\n\n````\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\u003c!-- prettier-ignore --\u003e\n```ts\nconst devboxView = await client.devboxes.create().catch(async (err) =\u003e {\n  if (err instanceof Runloop.APIError) {\n    console.log(err.status); // 400\n    console.log(err.name); // BadRequestError\n    console.log(err.headers); // {server: 'nginx', ...}\n  } else {\n    throw err;\n  }\n});\n```typescript\nimport { RunloopSDK, type DevboxView } from '@runloop/api-client';\n\nconst runloop = new RunloopSDK();\nconst devbox: DevboxView = await runloop.devbox.create();\n````\n\n// If you have access to Node `fs` we recommend using `fs.createReadStream()`:\nawait client.devboxes.uploadFile('id', {\npath: 'path',\nfile: fs.createReadStream('/path/to/file'),\n});\n\n## Advanced Configuration\n\nCustomize the SDK with your API token, endpoint, timeout, and retry settings:\n\n```typescript\nconst runloop = new RunloopSDK({\n  bearerToken: process.env.RUNLOOP_API_KEY,\n  timeout: 60000, // 60 second timeout\n  maxRetries: 3, // Retry failed requests\n});\n```\n\n## Error Handling\n\nThe SDK provides comprehensive error handling with typed exceptions:\n\n```typescript\ntry {\n  const devbox = await runloop.devbox.create();\n  const result = await devbox.cmd.exec('invalid-command');\n} catch (error) {\n  if (error instanceof RunloopSDK.APIError) {\n    console.log('API Error:', error.status, error.message);\n  } else if (error instanceof RunloopSDK.APIConnectionError) {\n    console.log('Connection Error:', error.message);\n  } else {\n    console.log('Unexpected Error:', error);\n  }\n}\n```\n\n### Logging and middleware\n\nYou may also provide a custom `fetch` function when instantiating the client,\nwhich can be used to inspect or alter the `Request` or `Response` before/after each request:\n\n```ts\nimport { fetch } from 'undici'; // as one example\nimport { RunloopSDK } from '@runloop/api-client';\n\nconst runloop = new RunloopSDK({\n  fetch: async (url: RequestInfo, init?: RequestInit): Promise\u003cResponse\u003e =\u003e {\n    console.log('About to make a request', url, init);\n    const response = await fetch(url, init);\n    console.log('Got response', response);\n    return response;\n  },\n});\n```\n\nNote that if given a `DEBUG=true` environment variable, this library will log all requests and responses automatically.\nThis is intended for debugging purposes only and may change in the future without notice.\n\n### Configuring an HTTP(S) Agent (e.g., for proxies)\n\nBy default, this library uses a stable agent for all http/https requests to reuse TCP connections, eliminating many TCP \u0026 TLS handshakes and shaving around 100ms off most requests.\n\nIf you would like to disable or customize this behavior, for example to use the API behind a proxy, you can pass an `httpAgent` which is used for all requests (be they http or https), for example:\n\n\u003c!-- prettier-ignore --\u003e\n```ts\n// Configure the default for all requests:\nconst runloop = new RunloopSDK({\n  httpAgent: new HttpsProxyAgent(process.env.PROXY_URL),\n});\n\n// Override per-request:\nawait runloop.devboxes.create({...}, {\n  httpAgent: new http.Agent({ keepAlive: false }),\n});\n```\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/runloopai/api-client-ts/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript \u003e= 4.5 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frunloopai%2Fapi-client-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frunloopai%2Fapi-client-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frunloopai%2Fapi-client-ts/lists"}