Generate a response

Generates a response for the provided prompt

post/api/generate

Request body

modelstring required

Model name

promptstring

Text for the model to generate a response from

suffixstring

Used for fill-in-the-middle models, text that appears after the user prompt and before the model response

imagesstring[]
systemstring

System prompt for the model to generate a response from

streamboolean

When true, returns a stream of partial responses

rawboolean

When true, returns the raw response from the model without any prompt templating

logprobsboolean

Whether to return log probabilities of the output tokens

top_logprobsinteger

Number of most likely tokens to return at each token position when logprobs are enabled

Response

Generation responses

modelstring

Model name

created_atstring

ISO 8601 timestamp of response creation

responsestring

The model's generated text response

thinkingstring

The model's generated thinking output

doneboolean

Indicates whether generation has finished

done_reasonstring

Reason the generation stopped

total_durationinteger

Time spent generating the response in nanoseconds

load_durationinteger

Time spent loading the model in nanoseconds

prompt_eval_countinteger

Number of input tokens in the prompt

prompt_eval_durationinteger

Time spent evaluating the prompt in nanoseconds

eval_countinteger

Number of output tokens generated in the response

eval_durationinteger

Time spent generating tokens in nanoseconds

Changes

Changed in 3 of the 9 revisions of this API.5

    • added the new max enum value to the request property think/oneOf[subschema #2]/

      request-property-enum-value-added

    • added the new optional request property logprobs

      new-optional-request-property

    • added the new optional request property top_logprobs

      new-optional-request-property

    • added the optional property logprobs to the response with the 200 status

      response-optional-property-added

    • request property think list-of-types was widened by adding types string to media type application/json

      request-property-list-of-types-widened