Skip to main content

Choose parameters

The DTO uses pointers for most optional sampling fields to distinguish omission from 0 / false. However, the OpenAI adapter can remove unsupported temperature, top_p, logprobs, and top_logprobs according to model capabilities. HTTP success does not prove every parameter took effect. Do not copy Chat’s seed, penalty, and logprobs example directly into Responses.

Read logprobs

Non-streaming Chat places metadata in choices[].logprobs.content: entries contain token, logprob, optional bytes, and top_logprobs. This describes token sampling, not answer correctness or factual accuracy; very-low-probability sentinel values are not precise probabilities. Streaming metadata sits in each choice’s logprobs, outside delta.content; accumulate it by choice and order. Ordinary OpenAI response forwarding retains raw fields. Channel ForceFormat rebuilding or protocol conversion does not guarantee preservation of extra logprobs metadata. If missing, check model support, request filtering, and the actual response path. The example explicitly sends zero values and requests two alternatives. It requires completed text and nonempty token metadata, permits empty alternative arrays, and does not require an exact alternative count. It validates finite nonpositive numbers, byte ranges, and refusal/tool/truncation states before printing text and token probabilities, excluding raw responses and reasoning fields. One request without retries; local tests do not establish upstream reproducibility or probability quality. Implementation sources: relaykit/dto/openai_request.go, relay/channel/openai/adaptor.go, and relay/channel/openai/relay-openai.go. See Chat API and parameter filtering.

Run the example

Run from the documentation directory with approved inputs and a capable model; first read the REST runtime. Keep the script and http-client.mjs together.
阅读中文 Related guide: Predicted outputs