llama-stack-mirror/docs/docs/api/generate-an-open-ai-compatible-completion-for-the-given-prompt-using-the-specified-model.api.mdx
Alexey Rybak 0b6725ac7a api docs
2025-09-23 10:00:13 -07:00

68 lines
12 KiB
Text

---
id: generate-an-open-ai-compatible-completion-for-the-given-prompt-using-the-specified-model
title: "Generate an OpenAI-compatible completion for the given prompt using the specified model."
description: "Generate an OpenAI-compatible completion for the given prompt using the specified model."
sidebar_label: "Generate an OpenAI-compatible completion for the given prompt using the specified model."
hide_title: true
hide_table_of_contents: true
api: eJztWm1P3DgQ/itWPt1JsGyrq3rlG+V6d0hUIKA6nShaeRNn49axU9tZWCH+e2dsZ+NNArvbFqmVlg+8JPZ4Xp5nZjzLfaKZqZQ0zCSH98nL8Rh/ZMykmleWK5kcJkeSnFVMHp0cq7ISDJ+Okr0kVdIyaXE9rSrBU4pvDj4Z3HSfmLRgJcXf7KJiIEZNP7HUwsZKq4ppy/2RPIvWGKu5nCUPIL1QPPUrwjuqNV3Adm5ZadbLzbnkpphoRoNCvSMsu7ODL7jM2F30hoOhM6bxlVAzOGa6wfmRe77NAKs+s2HFpwu7kWeWereKR29lXU69UVZVkwHDflJ94SXNMo5go+I8UiGnwrA9APSXmmsGsLoOOrXSbsBYbgWK85C+UtWpmp3ju70O7K8KRsAzBPYS3EynXHC7ILnShBInmeRalYQ2/NhPgSDAgqlgJC2oJemSMKSh2QgM+B4LOtEaMAjWP2XSDzene8hvZ5W37HfSPw/MdCda51w40xAu3V8lM4bOGMrTLK8NFT8/FHfU2VHnZ6LOOu+s2nvsSuxp44/1Fq/V4BuDukVMV6t6qOFNxe5FtG1YvK09G4+I7zOeUvwxnVNQwrJsuE8oVcbEIKNDCui9cg2VgRfOpkl7rFM6p7UYereV86DVahur1oBG26VuT/ix58GL4JNNPfilZsY6JoPmfwy1m4i7sI7cUoTYnAqeEQBeSQXgr3Q6/6D201hq66FM2jX036urc+JXg0WZK1TBS/1Qrm59pzWyBhfvQcIwhdKWmLosqV4QlTsGMbfmt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3XNJn5avEF5aatZqI5DH4tFA3JT5zm/21pNvw0wRy220LXIsKxDvwH12fML4ZhG/6iwVZvYDMJDge8MwilvB+HN+M71Za0Iq2uGGRRIouDPpFJuxAf9VwF/HcxfHCgnCH+LkliCWQWvVsahv9bYERbWVocHB1Qu9gsQw7J9ge3KvsF2ZQS7EyS+YdAjckxzsPGv5h51fYPvsPe6aLu0d21HGrqs1utNS9M+WRb6cVOV0bjBgjruFMGV0uR3xTVl7LL/eChVj5v0Om4yZKtQk668wF6W6XJyvCTUuOFEK6sD7+vmzc0AfMctWlf+SST3jUoASNxKXoa7Cw0fmWBgPZznLwY6WbzqmZVLD42vYbFkB3zQaw7qm4+SdL7gXsncPLdpV41ra0EK18AK7fN0hk0+clHnNMXSj0KpZh8l3kWUdkTqC0dAEAHXNo0f9Xmt3rvu2NddwCjcKNEnEu4Jz3sXWXFhdPd4zjNDosKP4A4qQbl0yVa7y4on+LWPr6c4xv2Fm1G0NAd4IZVx5f39lBr2QYuHB3wMlNILf69yl/4pguoa61MBN3QEL9D7M4MlybE3dv8K9cHlonaZuXvpwnrndxylKavsk2tvoqR1fnZ5hQkgXOzQAfBU01t4iN8PE2fksry7Z/eJoHJW4+fQh4mXiV9fAUbycpA=
sidebar_class_name: "post api-method"
info_path: docs/api/llama-stack-specification
custom_edit_url: null
---
import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
import ParamsDetails from "@theme/ParamsDetails";
import RequestSchema from "@theme/RequestSchema";
import StatusCodes from "@theme/StatusCodes";
import OperationTabs from "@theme/OperationTabs";
import TabItem from "@theme/TabItem";
import Heading from "@theme/Heading";
<Heading
as={"h1"}
className={"openapi__heading"}
children={"Generate an OpenAI-compatible completion for the given prompt using the specified model."}
>
</Heading>
<MethodEndpoint
method={"post"}
path={"/v1/openai/v1/completions"}
context={"endpoint"}
>
</MethodEndpoint>
Generate an OpenAI-compatible completion for the given prompt using the specified model.
<Heading
id={"request"}
as={"h2"}
className={"openapi-tabs__heading"}
children={"Request"}
>
</Heading>
<ParamsDetails
parameters={[]}
>
</ParamsDetails>
<RequestSchema
title={"Body"}
body={{"content":{"application/json":{"schema":{"type":"object","properties":{"model":{"type":"string","description":"The identifier of the model to use. The model must be registered with Llama Stack and available via the /models endpoint."},"prompt":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}},{"type":"array","items":{"type":"integer"}},{"type":"array","items":{"type":"array","items":{"type":"integer"}}}],"description":"The prompt to generate a completion for."},"best_of":{"type":"integer","description":"(Optional) The number of completions to generate."},"echo":{"type":"boolean","description":"(Optional) Whether to echo the prompt."},"frequency_penalty":{"type":"number","description":"(Optional) The penalty for repeated tokens."},"logit_bias":{"type":"object","additionalProperties":{"type":"number"},"description":"(Optional) The logit bias to use."},"logprobs":{"type":"boolean","description":"(Optional) The log probabilities to use."},"max_tokens":{"type":"integer","description":"(Optional) The maximum number of tokens to generate."},"n":{"type":"integer","description":"(Optional) The number of completions to generate."},"presence_penalty":{"type":"number","description":"(Optional) The penalty for repeated tokens."},"seed":{"type":"integer","description":"(Optional) The seed to use."},"stop":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}],"description":"(Optional) The stop tokens to use."},"stream":{"type":"boolean","description":"(Optional) Whether to stream the response."},"stream_options":{"type":"object","additionalProperties":{"oneOf":[{"type":"null"},{"type":"boolean"},{"type":"number"},{"type":"string"},{"type":"array"},{"type":"object"}]},"description":"(Optional) The stream options to use."},"temperature":{"type":"number","description":"(Optional) The temperature to use."},"top_p":{"type":"number","description":"(Optional) The top p to use."},"user":{"type":"string","description":"(Optional) The user to use."},"guided_choice":{"type":"array","items":{"type":"string"}},"prompt_logprobs":{"type":"integer"},"suffix":{"type":"string","description":"(Optional) The suffix that should be appended to the completion."}},"additionalProperties":false,"required":["model","prompt"],"title":"OpenaiCompletionRequest"}}},"required":true}}
>
</RequestSchema>
<StatusCodes
id={undefined}
label={undefined}
responses={{"200":{"description":"An OpenAICompletion.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"choices":{"type":"array","items":{"type":"object","properties":{"finish_reason":{"type":"string"},"text":{"type":"string"},"index":{"type":"integer"},"logprobs":{"type":"object","properties":{"content":{"type":"array","items":{"type":"object","properties":{"token":{"type":"string"},"bytes":{"type":"array","items":{"type":"integer"}},"logprob":{"type":"number"},"top_logprobs":{"type":"array","items":{"type":"object","properties":{"token":{"type":"string"},"bytes":{"type":"array","items":{"type":"integer"}},"logprob":{"type":"number"}},"additionalProperties":false,"required":["token","logprob"],"title":"OpenAITopLogProb","description":"The top log probability for a token from an OpenAI-compatible chat completion response."}}},"additionalProperties":false,"required":["token","logprob","top_logprobs"],"title":"OpenAITokenLogProb","description":"The log probability for a token from an OpenAI-compatible chat completion response."},"description":"(Optional) The log probabilities for the tokens in the message"},"refusal":{"type":"array","items":{"type":"object","properties":{"token":{"type":"string"},"bytes":{"type":"array","items":{"type":"integer"}},"logprob":{"type":"number"},"top_logprobs":{"type":"array","items":{"type":"object","properties":{"token":{"type":"string"},"bytes":{"type":"array","items":{"type":"integer"}},"logprob":{"type":"number"}},"additionalProperties":false,"required":["token","logprob"],"title":"OpenAITopLogProb","description":"The top log probability for a token from an OpenAI-compatible chat completion response."}}},"additionalProperties":false,"required":["token","logprob","top_logprobs"],"title":"OpenAITokenLogProb","description":"The log probability for a token from an OpenAI-compatible chat completion response."},"description":"(Optional) The log probabilities for the tokens in the message"}},"additionalProperties":false,"title":"OpenAIChoiceLogprobs","description":"The log probabilities for the tokens in the message from an OpenAI-compatible chat completion response."}},"additionalProperties":false,"required":["finish_reason","text","index"],"title":"OpenAICompletionChoice","description":"A choice from an OpenAI-compatible completion response."}},"created":{"type":"integer"},"model":{"type":"string"},"object":{"type":"string","const":"text_completion","default":"text_completion"}},"additionalProperties":false,"required":["id","choices","created","model","object"],"title":"OpenAICompletion","description":"Response from an OpenAI-compatible completion request."}}}},"400":{"description":"The request was invalid or malformed","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"integer","description":"HTTP status code"},"title":{"type":"string","description":"Error title, a short summary of the error which is invariant for an error type"},"detail":{"type":"string","description":"Error detail, a longer human-readable description of the error"},"instance":{"type":"string","description":"(Optional) A URL which can be used to retrieve more information about the specific occurrence of the error"}},"additionalProperties":false,"required":["status","title","detail"],"title":"Error","description":"Error response from the API. Roughly follows RFC 7807."},"example":{"status":400,"title":"Bad Request","detail":"The request was invalid or malformed"}}}},"429":{"description":"The client has sent too many requests in a given amount of time","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"integer","description":"HTTP status code"},"title":{"type":"string","description":"Error title, a short summary of the error which is invariant for an error type"},"detail":{"type":"string","description":"Error detail, a longer human-readable description of the error"},"instance":{"type":"string","description":"(Optional) A URL which can be used to retrieve more information about the specific occurrence of the error"}},"additionalProperties":false,"required":["status","title","detail"],"title":"Error","description":"Error response from the API. Roughly follows RFC 7807."},"example":{"status":429,"title":"Too Many Requests","detail":"You have exceeded the rate limit. Please try again later."}}}},"500":{"description":"The server encountered an unexpected error","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"integer","description":"HTTP status code"},"title":{"type":"string","description":"Error title, a short summary of the error which is invariant for an error type"},"detail":{"type":"string","description":"Error detail, a longer human-readable description of the error"},"instance":{"type":"string","description":"(Optional) A URL which can be used to retrieve more information about the specific occurrence of the error"}},"additionalProperties":false,"required":["status","title","detail"],"title":"Error","description":"Error response from the API. Roughly follows RFC 7807."},"example":{"status":500,"title":"Internal Server Error","detail":"An unexpected error occurred. Our team has been notified."}}}},"default":{"description":"An unexpected error occurred","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"integer","description":"HTTP status code"},"title":{"type":"string","description":"Error title, a short summary of the error which is invariant for an error type"},"detail":{"type":"string","description":"Error detail, a longer human-readable description of the error"},"instance":{"type":"string","description":"(Optional) A URL which can be used to retrieve more information about the specific occurrence of the error"}},"additionalProperties":false,"required":["status","title","detail"],"title":"Error","description":"Error response from the API. Roughly follows RFC 7807."},"example":{"status":0,"title":"Error","detail":"An unexpected error occurred"}}}}}}
>
</StatusCodes>