PRODUCTION USE CASE

LLM API for code review

A pull request changes authentication middleware. The review service sends the diff, nearby functions, repository security rules, and the changed-line map to codex-auto-review. The model must return only findings that identify a concrete failure path.

Pull request diff with a high-risk input-validation finding
LLM API for code review

Production recipe

API, primary model, and failover configuration

Production choiceRecommendationWhy
APIPOST /v1/chat/completionsOpenAI-compatible server-side request
Primary modelcodex-auto-reviewcodex-auto-review is the purpose-specific first route currently exposed by Model Plaza for automated review.
Fallback modelgpt-5.6-terraUse Terra when the review needs broader repository reasoning; escalate a disputed high-risk finding to Sol, not every ordinary PR.
Escalation modelgpt-5.6-solUse only when the primary route fails the defined quality or complexity boundary
Output contractValidated JSONJSON findings: file, line, severity, title, evidence, failure path, and suggested fix.
01
Scenario

Code review in a production application

A pull request changes authentication middleware. The review service sends the diff, nearby functions, repository security rules, and the changed-line map to codex-auto-review. The model must return only findings that identify a concrete failure path.

The service rejects comments without a file, changed line, severity, evidence, and repair. Clean pull requests are part of the evaluation set, so producing more comments is not treated as better review.

02
Architecture

How the code review workflow operates

  • Build the diff and changed-line map.
  • Retrieve only directly relevant code and repository rules.
  • Request structured findings with evidence and a minimal line range.
  • Drop malformed and out-of-diff comments unless their dependency path is proven.
  • Show accepted findings to a human reviewer.
03
API request

Call codex-auto-review through LLMFly AI

Send the request from your server. Replace the example content and placeholder tool schema with data and tools from your application.

request.exampleCopy-ready
curl https://app.llmfly.ai/v1/chat/completions \
  -H "Authorization: Bearer $LLMFLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "codex-auto-review",
    "messages": [
      {"role": "system", "content": "Review the supplied diff. Report only actionable defects introduced by this change. Each finding needs file, changed line, severity, failure path, evidence, and a minimal fix."},
      {"role": "user", "content": "Review this authentication middleware pull request against the attached repository rules."}
    ],
    "response_format": {"type": "json_object"}
  }'
04
Model choice

Why codex-auto-review is the primary model

codex-auto-review is the purpose-specific first route currently exposed by Model Plaza for automated review.

Use Terra when the review needs broader repository reasoning; escalate a disputed high-risk finding to Sol, not every ordinary PR.

05
Acceptance

Acceptance checks for code review

MetricPass condition
True-defect recallFinds the seeded high-risk defects in the evaluation set
False-positive rateClean control changes receive no blocking or invented finding
Line-level groundingEvery finding points to the smallest relevant line range and explains the failure path
Reviewer acceptance rateQualified reviewers judge the comment correct, actionable, and worth showing
06
Failure handling

Failures to handle before deployment

  • Rewarding comment volume
  • Using only defective examples
  • Accepting vague best-practice advice
  • Commenting outside changed lines without evidence
07
Output

Returned output and run records

JSON findings: file, line, severity, title, evidence, failure path, and suggested fix.

Record the model ID, request ID, token usage, retries, validation result, and final disposition for every production run.

Frequently asked questions

How do I measure false positives?

Include clean changes and count findings a qualified reviewer rejects as incorrect or non-actionable.

Does code review need the whole repository?

Not always. Start with the diff and directly relevant files, then retrieve more context when needed.

What output format works best?

Use a schema with file, line, severity, explanation, evidence, and suggested remediation.

Test this setup with your own inputs

Compare the primary and fallback models with the same requests, tools, and validation rules.

Compare models