Text Generation
An overview of LLM generation parameters
You can paste the command below into your terminal to run your first API request. Make sure to replace YOUR_KEYWORDSAI_API_KEY
with your actual Keywords AI API key.
Example Call
OpenAI Parameters
List of messages to send to the endpoint in the OpenAI style, each of them following this format:
Image Processing If you want to use the image processing feature, you need to use the following format to upload the image
Maximum number of tokens to generate in the response
Controls randomness in the output in the range of 0-2, higher temperature will a more random response.
Specify many completion choices to generate for each prompt.
Caveat! While this can help improve generation quality by picking the optimal choice, this could also lead to more token usage.
Whether to stream back partial progress token by token
Include the log probabilities on each token being selected.
Echo back the prompt in addition to the completion
Stop sequence
Specify how much to penalize new tokens based on whether they appear in the text so far. Increases the model’s likelihood of talking about new topics
Specify how much to penalize new tokens based on their existing frequency in the text so far. Decreases the model’s likelihood of repeating the same line verbatim
Used to modify the probability of tokens appearing in the response
A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide an array of functions the model may generate JSON inputs for.
Manually picking the choice of tool for the model to use. This will force the model to make a function call every time a function is passed in.
Keywords AI Parameters
Adding this returns the summarization of the response in the response body. If streaming is on, the metrics will be streamed as the last chunk
Specify the list of models for the router to choose between. If not specified, all models will be used. See the list of models here
If only one model is specified, it will be treated as if model
parameter is used and the router will not trigger.
Specify the list of backup models (ranked by priority) to respond in case of a failure in the primary model. See the list of models here
You can pass in a dictionary of your customer’s credentials and deployment variables for supported providers and use their credits when the router is calling models from those providers.
Use this as a tag to identify the user associated with the API call.
You can add any key-value pair to this metadata field for your reference, contact team@keywordsai.co if you need extra parameter support for your use case.
Example:
When set to true, only the request and the performance metrics will be recorded, input and output messages will be omitted from the log.
The list of models to exclude from the router’s selection. See the list of models here
This only excludes models in the router, if model
parameter will take precedence over this parameter, andfallback_models
and safety net will still use the excluded models to catch failures.
The list of providers to exclude from the router’s selection. All models under the provider will be excluded. See the list of providers here
This only excludes models in the router, if model
parameter will take precedence over this parameter, andfallback_models
and safety net will still use the excluded models to catch failures.
Deprecated Parameters
You can pass in a dictionary of your customer’s API keys for specific models. If the router selects a model that is in the dictionary, it will attempt to use the customer’s API key for calling the model before using your integration API key or Keywords AI’s default API key.