Skip to content

Support OpenAI Predicted Output (prediction parameter) #130

Description

@sotaky

OpenAI added a prediction parameter to chat completions that lets you pass a predicted completion for the model to validate or refine. This significantly reduces latency and cost for rewrite/edit tasks where you already have a good guess at the output:

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": "Fix typos in the given text."},
        {"role": "user", "content": "The quik brown fox jumpd over the layz dog."},
    ],
    prediction={
        "type": "content",
        "content": "The quick brown fox jumped over the lazy dog."
    },
)

When the prediction is close to what the model would generate anyway, the provider uses speculative decoding internally — the response comes back faster and costs less because fewer tokens need to be generated from scratch.

OrcaRouter drops this parameter (same ChatCompletionRequest schema gap). I'd like to see it forwarded as a pass-through. Since it's a structured dict ({"type": "content", "content": "..."}), adding prediction: dict | None = None to the schema should be sufficient.

One routing consideration: predicted output is currently only supported by OpenAI's gpt-4o family. If model="auto" receives a request with prediction, the auto-router should only consider models whose upstream is OpenAI and whose model supports predicted output. Otherwise the parameter reaches an upstream that rejects it with a 400.

Happy to help test if someone picks this up.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions