synth contracts command provides access to OpenAPI specifications for building Task Apps and integrating with Synth services.
Overview
OpenAPI contracts define the HTTP interface between your code and Synth’s optimization services. These contracts enable you to:- Build Task Apps in any language (Rust, Go, TypeScript, Zig, etc.)
- Generate type-safe client/server code
- Validate your implementation against the specification
- Understand required endpoints and data structures
Commands
show
Display a contract’s contents in your terminal.- Read directly in your terminal
- Pipe to a file:
synth contracts show task-app > task_app.yaml - Use with other tools:
synth contracts show task-app | yq
path
Get the file system path to a contract (useful for code generators).Available Contracts
task-app
The Task App contract defines the HTTP interface that Task Apps must implement for prompt optimization and reinforcement learning. Endpoints:GET /health- Health check (unauthenticated)POST /rollout- Execute a rollout with a specific prompt/policyGET /task_info- Get task metadata and dataset information (optional)
- Building Task Apps in non-Python languages
- Generating type-safe bindings for your language
- Understanding the request/response structure
- Validating your Task App implementation
Examples
Generate Rust Types
Generate Go Types
Generate TypeScript Types
Validate Against the Contract
Use tools like openapi-validator to check if your implementation matches the contract:Building Without Python
You can access contracts without installing the Python SDK:Direct Download
View in Browser
- GitHub: https://github.com/synth-laboratories/synth-ai/blob/main/synth_ai/contracts/task_app.yaml
- Raw: https://raw.githubusercontent.com/synth-laboratories/synth-ai/main/synth_ai/contracts/task_app.yaml
Contract Structure
Each contract includes:- Type Definitions - Complete schemas for all request/response objects
- Endpoint Specifications - Paths, methods, and parameters
- Authentication Requirements - Which endpoints require API keys
- Behavioral Documentation - How to implement the logic (in descriptions)
- Example Payloads - Sample requests and responses
- Error Schemas - Proper error response formats
Integration Workflow
Here’s a typical workflow for building a Task App in a non-Python language:-
Get the contract:
-
Generate types (optional):
-
Implement the endpoints:
- Read the behavioral documentation in the contract
- Implement
/health,/rollout, and optionally/task_info - Use generated types for type safety
-
Test locally:
-
Deploy and connect:
See Also
- Polyglot Task Apps Guide - Complete guide with examples
- Task App Documentation - Python Task App guide
- Deployed Task App Walkthrough - Step-by-step deployment
Common Issues
Contract Not Found
If you see an error like “Contract ‘xyz’ not found”, make sure you’re using the correct contract name:Code Generator Fails
Ifopenapi-generator fails, ensure:
- You have the generator installed:
npm install -g @openapitools/openapi-generator-cli - The contract file exists and is valid YAML
- You’re using a supported generator:
openapi-generator list
Types Don’t Match Runtime
If generated types don’t match actual responses:- Make sure you’re using the latest version of synth-ai
- Regenerate types:
synth contracts show task-app > contract.yaml && openapi-generator generate ... - Check if you’re using the correct version of the contract