Completions
Use this API to generate completions from a project. See the API section of your endpoint on the Baseplate console for copy-pasteable code.
Generates a completion
Generates a completion from endpoint . Your endpoint ID can be found in the API tab of your endpoint or in the URL.
Parameters
Paths
Baseplate endpoint ID
Header
Baseplate API key. Needs to be in the format “Bearer &BASEPLATE_API_KEY”
Use application/json
Body
A json object with keys matching the variables of your deployed template
A prompt for Anthropic, ada, babbage, curie, and davinci models. One of messages or prompt is required.
An array of the chat history, for gpt-3.5 and gpt-4 models. One of messages or prompt is required.
If true, response will be sent back as Server Sent Events. A [DONE] message is sent at the end of the completion and the search results (if applicable) are sent after the [DONE]. See below for example.
A user string to use for OpenAI’s API.
Steaming Example (Next.js 13)
Heres an example if you are using NextJS 13/React:
Backend (/api/completions/chat/route.ts):
Front end (inside some function):