Skip to main content
POST https://api.prysm1.com/v2/code · Requires authentication
Code Mode writes code, reviews it with a separate critic model, and repairs against that feedback until the review passes or a budget/iteration cap is hit (Reflexion-style). In depth policy several diverse coders run in parallel and the best candidate is kept. The response carries the files, the final review verdict, and a PrysmProof v2 that binds the task to the code it produced. You pick the objective with a policy; PRYSM picks the coder and the critic (or you force them). See How Code Mode works for the full model.
This endpoint lives under /v2, not /v1. The SDKs target it automatically with client.code(...). PRYSM never executes the generated code — the default critic is a pure LLM reviewer.

Authorization

Authorization
string
required
Your secret key as a bearer token: Bearer prysm_sk_...

Body

task
string
required
The coding task in natural language, e.g. “Write a thread-safe LRU cache in Python with tests”.
language
string
Target language (python, typescript, rust, …). Auto-detected from the task if omitted.
policy
string
default:"balanced"
The objective dial: efficiency (one cheap coder), depth (cross several diverse coders in parallel and keep the best), or balanced.
coder_model
string
Force the model that writes the code. Ignored if it isn’t a known catalog model.
reviewer_model
string
Force the critic model that reviews the code. Ignored if it isn’t a known catalog model.
max_iters
integer
default:"3"
Total iterations: the first generation plus up to max_iters - 1 repairs.
review
boolean
default:"true"
Set false for a single shot — one coder, one draft, no critic loop.
max_tokens
integer
default:"2048"
Maximum tokens per underlying model call.
temperature
number
default:"0.2"
Sampling temperature passed to the underlying models. Lower is steadier for code.
max_cost_usd
number
A soft budget hint, in USD. The repair loop stops early once the estimated spend approaches this cap.
include_trace
boolean
default:"true"
Include the per-stage execution trace in prysm.stages. Set false for a leaner response.

Response

id
string
Unique code-run id, e.g. prysm-a1b2c3d4.
object
string
Always code.
created
integer
Unix timestamp (seconds).
task
string
The task that was solved.
language
string
The target language (detected or forced).
policy
string
The policy that ran: efficiency, balanced, or depth.
reason
string
Plain-English explanation of how the run was carried out.
passed
boolean
Whether the final review passed.
iterations
integer
How many generate→review cycles ran.
files
array
The generated files.
review
object
The final critic verdict, or null when review was false.
usage
object
Aggregate token usage across every model call.
prysm
object
The Code Mode extension block.

Errors

StatuserrorMeaning
400no_tasktask was empty or whitespace.
401Missing or invalid API key.
502no_code_producedKeys are configured but no model produced usable code.
502code_errorThe engine raised while generating or reviewing.
503no_provider_availableNo provider API keys are configured on the server.
from prysm import Prysm

client = Prysm()
r = client.code(
    "Write a Python function to add two numbers",
    policy="balanced",
)
for f in r["files"]:
    print(f["path"]); print(f["content"])
print(r["passed"], r["prysm"]["proof"]["proof_hash"])
{
  "id": "prysm-a1b2c3d4",
  "object": "code",
  "created": 1767312000,
  "task": "Write a Python function to add two numbers",
  "language": "python",
  "policy": "balanced",
  "reason": "balanced policy: one mid-tier coder, reviewed and repaired by a reasoning critic.",
  "passed": true,
  "iterations": 1,
  "files": [
    {
      "path": "main.py",
      "language": "python",
      "content": "def add(a, b):\n    \"\"\"Return the sum of two numbers.\"\"\"\n    return a + b\n",
      "bytes": 71
    }
  ],
  "review": {
    "passed": true,
    "score": 0.92,
    "issues": [],
    "reviewer": "deepseek-r1"
  },
  "usage": {
    "prompt_tokens": 86,
    "completion_tokens": 120,
    "total_tokens": 206
  },
  "prysm": {
    "code": {
      "policy": "balanced",
      "language": "python",
      "passed": true,
      "score": 0.92,
      "confidence": 0.9,
      "iterations": 1,
      "coder_models": ["qwen-2.5-72b"],
      "reviewer_model": "deepseek-r1",
      "models_used": ["qwen-2.5-72b", "deepseek-r1"],
      "latency_ms": 3180
    },
    "cost": { "total_usd": 0.000412, "estimated": true },
    "proof": {
      "request_id": "a1b2c3d4-...-...",
      "timestamp": "2026-06-03T00:00:00+00:00",
      "proof_hash": "sha256:7f3a9c2b1e4d8a06",
      "policy": "balanced",
      "language": "python",
      "passed": true,
      "models_used": ["qwen-2.5-72b", "deepseek-r1"],
      "confidence": 0.9,
      "verifiable": true
    },
    "stages": [
      {
        "name": "plan",
        "results": [],
        "detail": { "language": "python", "policy": "balanced", "coder_models": ["qwen-2.5-72b"], "reviewer_model": "deepseek-r1" }
      },
      {
        "name": "generate:0",
        "results": [
          { "model": "qwen-2.5-72b", "ok": true, "in_tokens": 42, "out_tokens": 78, "latency_ms": 1620, "cost_usd": 0.00021, "confidence": 0.8, "role": "coder" }
        ],
        "detail": { "iteration": 0 }
      },
      {
        "name": "review:0",
        "results": [
          { "model": "deepseek-r1", "ok": true, "in_tokens": 44, "out_tokens": 42, "latency_ms": 1560, "cost_usd": 0.0002, "confidence": 0.92, "role": "reviewer" }
        ],
        "detail": { "passed": true, "score": 0.92 }
      }
    ]
  }
}