Why Polyglot Task Apps?
- Use your preferred language - No need to rewrite existing code in Python
- Better performance - Compiled languages can be faster for CPU-intensive tasks
- Smaller deployments - Single binaries with no runtime dependencies
- Existing codebases - Integrate directly with your current infrastructure
- No Python required - Start optimization jobs via API calls
How It Works
/rollout endpoint with candidate prompts, and you return a reward indicating how well each prompt performed.
The Contract
All Task Apps implement the same OpenAPI contract, regardless of language: Required Endpoints:GET /health- Health check (unauthenticated OK)POST /rollout- Evaluate a prompt (authenticated)
GET /task_info- Dataset metadata (authenticated)
env.seed- Dataset indexpolicy.config.inference_url- LLM endpointpolicy.config.prompt_template- The prompt to evaluate
metrics.mean_return- Reward (0.0-1.0) that drives optimizationtrajectories[].steps[].reward- Per-step reward
Accessing the Contract
Via CLI
Direct Download
Generate Types
Authentication
Task Apps involve two separate authentication flows:1. Task App Authentication (X-API-Key)
Requests to your task app from the optimizer include an X-API-Key header:
X-API-Key matches ENVIRONMENT_API_KEY.
2. LLM API Authentication (Authorization: Bearer)
When your task app makes requests to OpenAI/Groq/etc:
X-API-Key header from the optimizer is for task app auth only - do NOT forward it to the LLM API.
Running Optimization (No Python Required)
Start optimization jobs directly via API calls:Language Implementations
Rust
Fast, type-safe with Axum. Async/await with Tokio.
Go
Zero dependencies. Single static binary.
TypeScript
Hono framework. Deploy to Cloudflare Workers.
Zig
Smallest binaries. Trivial cross-compilation.
Performance Comparison
| Language | Binary Size | Dependencies | Startup Time | Cross-Compile |
|---|---|---|---|---|
| Rust | ~5-10MB | Some | Fast (~50ms) | Yes (via rustup) |
| Go | ~8-12MB | None | Very Fast (~10ms) | Yes (built-in) |
| TypeScript | N/A (Node) | Many | Medium (~200ms) | N/A |
| Zig | ~1-5MB | None | Very Fast (~10ms) | Yes (trivial) |
Debugging Tips
Testing Locally
Common Issues
- 404 errors from LLM endpoint: Check URL construction with query parameters
- Authentication failures: Verify
X-API-KeymatchesENVIRONMENT_API_KEY - Missing rewards: Ensure
rewardfield is present in each step - Tool call parsing: Extract predictions from
tool_callsorcontentcorrectly