Generate text and images using Together AI's API.
HTML form for interacting with the function.
Query the model for a completion.
Parameters
Name | Description | Location | Type | Sample Value |
---|---|---|---|---|
Content-Type | The content type of the request body | Header | application/json |
N/A |
prompt | Text to prompt the model | Body | String | Write a haiku about Mondays |
type | The type of completion to generate, can be text or image |
Body | String | text |
Sample 200
Response:
Response from the model.
{
"ok": true,
"response": "Monday's heavy weight, Dawning with a sigh of grey, Hopeful hearts await.",
"type": "text"
}
If you request an image the result will be uploaded to Appwrite Storage and the URL to access it will be returned. Make sure the bucket you give the function is setup to allow any
read access for the front end to work.
{
"ok": true,
"type": "image",
"response": "https://cloud.appwrite.io/v1/storage/buckets/together/files/661e173537dedbeec3cd/view?project=test"
}
Sample 400
Response:
Response when the request body is missing.
{
"ok": false,
"error": "Missing body with a prompt."
}
Sample 500
Response:
Response when the model fails to respond.
{
"ok": false,
"error": "Failed to query model."
}
Setting | Value |
---|---|
Runtime | Node (18.0) |
Entrypoint | src/main.js |
Build Commands | npm install |
Permissions | any |
Timeout (Seconds) | 900 |
A unique key used to authenticate with the Together AI API. Please note that this is a paid service and you will be charged for each request made to the API. For more information, see the Together AI pricing page.
Question | Answer |
---|---|
Required | Yes |
Sample Value | r8_...... |
Documentation | Together AI Docs |
The ID of the Appwrite storage bucket where the image files will be saved. It must have permissions set for any
read access for the front-end to work.
Question | Answer |
---|---|
Required | Yes |
Sample Value | 66019da664270f02c20c |
Documentation | Appwrite Docs |