Skip to content

Phi 4

POST/v1/chat/completions

Microsoft Research Phi-4 is designed to perform well in complex reasoning tasks and can operate efficiently in situations with limited memory or where quick responses are needed.

Request body

Parameters supported by this model. Values, defaults, and limits are read from the model registry.

stringmodelrequired

Model identifier. Set to microsoft/phi-4.

Default: microsoft/phi-4

array<object>messagesrequired

Conversation messages in system, user, or assistant order.

Optional<integer>max_tokens

Maximum number of tokens the model may generate in the response.

Range: −∞ to 16384

Optional<number>temperature

Sampling temperature. Lower values are more deterministic; higher values are more creative.

Range: 0 to 2

Default: 1

Optional<number>top_p

Nucleus sampling threshold. Use this or temperature, but usually not both.

Range: 0 to 1

Optional<boolean>stream

When true, returns incremental Server-Sent Events instead of one completed response.

Default: false

Optional<object>response_format

Controls the response format, including JSON mode or structured JSON output when supported.

Optional<array<string>>stop

Sequences that stop generation when the model produces one of them.

Optional<number>presence_penalty

Penalizes tokens that already appeared, encouraging the model to introduce new topics.

Range: -2 to 2

Optional<number>frequency_penalty

Penalizes repeated tokens, reducing repetition in the generated response.

Range: -2 to 2

Optional<integer>seed

Seed used to make sampling more reproducible when the provider supports it.

Optional<integer>top_k

Request parameter supported by this model.

Range: 0 to ∞

Response Schema

Fields returned by this model API response.

array<object>choicesrequired

Generated completion choices.

stringidrequired

Unique chat completion identifier.

stringmodelrequired

Model that generated the response.

Optional<object>usage

Token usage when available.

Model capabilities

array<string>capability_tagsrequired

Capabilities declared by the model registry.

Default: chat, structured_output

integercontext_lengthrequired

Maximum context window accepted by this model.

Default: 16384 tokens

stringexecution_moderequired

Execution mode declared by the model registry.

Default: sync