Skip to main content
# GEPA (Banking77)
cd synth-ai
uv run python /path/to/cookbooks/code/training/prompt_learning/gepa/run_walkthrough.py

Sources:

Prerequisites

  • Python 3.11+
  • uv package manager
  • Accounts + API keys set up for Synth AI and your models
  • Environment variables:
    • SYNTH_API_KEY
    • ENVIRONMENT_API_KEY
    • GROQ_API_KEY (or other model provider key, depending on config)

GEPA: Banking77 (In-Process)

Run a full GEPA optimization loop from a single script:
cd synth-ai
uv run python /path/to/cookbooks/code/training/prompt_learning/gepa/run_walkthrough.py
Source:
run_walkthrough.py · config.toml · walkthrough.md

What happens

  1. An in-process Container is started in a background thread.
  2. A Cloudflare tunnel is created automatically and registered with Synth AI.
  3. A GEPA prompt-learning job is submitted, monitored, and polled until completion.
  4. Final results are returned to Python, and the Container + tunnel are cleaned up automatically.

Sample results

Job pl_5ea04259c2fd4c7a83.33% accuracy on Banking77 in ~35 seconds.
{
  "job_id": "pl_5ea04259c2fd4c7a",
  "algorithm": "gepa",
  "dataset": "banking77",
  "best_score": 0.8333,
  "best_prompt_rank": 1,
  "num_generations": 8,
  "total_time_seconds": 35.6
}
See full run output in:
results.json

Core pattern (GEPA)

The walkthrough uses the same in-process pattern: start a Container, create a tunnel, run a prompt-learning job pointed at the tunnel URL, and clean everything up when done.
from synth_ai.sdk import InProcessContainer, OfflineJob


async def optimize_prompt(
    container_path: str,
    config_path: str,
    port: int = 8001,
):
    async with InProcessContainer(
        container_path=container_path,
        port=port,
    ) as container:
        # Build job from TOML config
        job = OfflineJob.from_config(
            config_path=config_path,
            container_url=container.url,
        )

        # Run until complete and fetch best prompt + metrics
        results = await job.poll_until_complete()

    return results
Minimal GEPA wrapper:
# GEPA
results = await optimize_prompt(
    container_path="container.py",
    config_path="code/training/prompt_learning/gepa/config.toml",
)
Full GEPA walkthrough:
gepa/walkthrough.md

Ready to get started?

Get Started

Sign up and start optimizing your prompts today.

Schedule Demo

See Synth in action with a personalized walkthrough.