.env
file with the name WRITER_API_KEY
.POST https://api.writer.com/v1/completions
/completions
endpoint results in charges for model usage. See the pricing page for more information.Parameter | Type | Description |
---|---|---|
model | string | Required. The ID of the model to use for text generation. |
prompt | string | Required. The prompt to generate text from. |
max_tokens | int | The maximum number of tokens to generate for the response. Defaults to 100 . |
temperature | float | Temperature influences the randomness in generated text. Defaults to 1 . Increase the value for more creative responses, and decrease the value for more predictable responses. |
stream | Boolean | A Boolean value that indicates whether to stream the response. Defaults to false . |
stream
parameter to false
, the response is a single JSON object with the following parameters:
Parameter | Type | Description |
---|---|---|
model | string | The ID of the model used to generate the response. |
choices | array | An array of choices objects. |
choices[0].text | string | The generated text. |
choices[0].log_probs | object | The log probabilities of the tokens in the generated text. |
stream
parameter to true
, the response is delivered as server-sent events with the following parameters:
Parameter | Description |
---|---|
value | The content of the chunk. |
palmyra-med
model, using the prompt “How can I treat a cold?”
choices[0].text
field.