Deploy a prompt
Deploy a prompt to your codebase.
After you create a prompt, you can deploy it to your codebase, and then you can call it through the API.
1. Find the Prompt ID
You should first find the Prompt ID of the prompt you want to deploy. You can find the Prompt ID in the Overview panel on the Prompts page.
2. Connect the prompt to codebase
Integrate the prompt to the codebase by adding the following code to your codebase.
Since OpenAI forces you to pass the model
and messages
fields, you should pass the an override
field to the prompt
field, which will override the model
and messages
fields and use the prompt you created in Keywords AI.
3. Deploy the prompt
Once you have connected the prompt to your codebase, you can deploy the prompt on the platform. You can deploy the prompt by clicking on the Deploy
button on the Prompts page.
Override prompt messages in the API
You can override the prompt messages in the API by passing the override_params
and override_config
field to the prompt
field.
You can choose to override the whole prompt messages or append a new message to the prompt messages.
Example:
In this example, the override_config
specifies how the new messages should be handled:
- When
messages_override_mode
is set to"append"
, the new message{"role": "user", "content": "5"}
will be added to the end of the existing prompt messages - When set to
"override"
, the new messages will completely replace the original prompt messages
4. View the logs with the prompt
You can view the logs with the prompt by clicking a log on the Logs page or filtering the logs with the prompt name.
Optional parameters
with echo on, the response body will have an extra field
Turn on override to use params in override_params
instead of the params in the prompt.
You can put any OpenAI chat/completions parameters here to override the prompt’s parameters. This will only work if override
is set to true
.
This parameter allows you to control how you can override the parameters in the prompt.
Troubleshooting
Enable stream when you’re using OpenAI SDK
If you’re using OpenAI SDK and want to connect with the prompt you created, you have to specify stream=True
in the call body.