Examples API Documentation
A prompt is sent with worked examples: each a request in natural language and the answer the model should give for it. They are how the model learns a catalog’s vocabulary. An example that is hidden is kept and not sent.
The quickest way to a good example is a search that read a request well, kept with POST .../searches/{id}/save_as_example. The model can also suggest requests of its own, below. Reading is open to every collaborator; changing takes the editor role and the catalog_write scope.
Endpoints
Retrieve the prompt’s examples, in order.
Path Parameters
| Name |
Type |
Description |
Required |
| library_id |
integer |
ID of the library |
Yes |
| ai_prompt_id |
integer |
ID of the prompt |
Yes |
Query Parameters
| Name |
Type |
Description |
| page |
integer |
Page number for pagination (default: 1) |
| per_page |
integer |
Records per page, up to 200 (default: 25) |
| active |
boolean |
true lists only the examples that are sent with the prompt, false only those that are hidden |
Response
{
"pagination": {
"total_entries": 12,
"per_page": 25,
"current_page": 1,
"total_pages": 1
},
"ai_search_examples": [
{
"id": 31,
"ai_prompt_id": 4,
"user_query": "upbeat rock songs about the open road",
"example_struct": {
"query": {
"filter": { "genre": { "value": "rock" } },
"boost": {
"mood": { "value": "upbeat", "weight": 50 },
"lyrical_theme": { "value": "driving on the open road", "weight": 40 }
}
}
},
"position": 1,
"active": true,
"created_at": "2024-08-19T13:30:26.166-05:00",
"updated_at": "2024-08-19T13:30:26.166-05:00",
"url": "https://app.spondulix.ai/api/v1/libraries/2/ai_prompts/4/ai_search_examples/31"
}
]
}
Response Fields
| Field |
Type |
Description |
| pagination |
object |
Contains pagination information |
| ai_search_examples |
array |
List of example objects |
| id |
integer |
ID of the example |
| ai_prompt_id |
integer |
ID of the prompt |
| user_query |
string |
The request in natural language |
| example_struct |
object |
The answer the model is shown for it |
| position |
integer |
Place in the order |
| active |
boolean |
Whether the example is sent with the prompt |
| created_at |
string |
Timestamp of when the example was created |
| updated_at |
string |
Timestamp of when the example was last updated |
| url |
string |
URL of the example |
HTTP Response Codes
| Code |
Description |
200 OK |
Successful request |
404 Not Found |
Invalid library ID or prompt ID |
Create an example.
Path Parameters
| Name |
Type |
Description |
Required |
| library_id |
integer |
ID of the library |
Yes |
| ai_prompt_id |
integer |
ID of the prompt |
Yes |
Request Body
Wrap the fields in an ai_search_example key.
| Field |
Type |
Description |
Required |
| user_query |
string |
The request (max 255 chars) |
Yes |
| example_struct |
object |
The answer the model should give: a JSON object, in the shape the prompt asks the model for |
Yes |
| position |
integer |
Place in the order. Last, unless given. |
No |
| active |
boolean |
Whether the example is sent with the prompt (default: true) |
No |
{
"ai_search_example": {
"user_query": "upbeat rock songs about the open road",
"example_struct": { "query": { "filter": { "genre": { "value": "rock" } } } }
}
}
Response
Returns the example as shown in the list response, with a Location header.
HTTP Response Codes
| Code |
Description |
201 Created |
Successful creation |
403 Forbidden |
Your role does not allow editing |
404 Not Found |
Invalid library ID or prompt ID |
422 Unprocessable Content |
Invalid request (see response body for details) |
Retrieve an example.
Path Parameters
| Name |
Type |
Description |
Required |
| library_id |
integer |
ID of the library |
Yes |
| ai_prompt_id |
integer |
ID of the prompt |
Yes |
| id |
integer |
ID of the example |
Yes |
Response
Returns the example as shown in the list response.
HTTP Response Codes
| Code |
Description |
200 OK |
Successful request |
404 Not Found |
Invalid library ID, prompt ID or example ID |
Change an example. PATCH works the same way, and only the fields you send change. The body takes the same fields as create.
Path Parameters
| Name |
Type |
Description |
Required |
| library_id |
integer |
ID of the library |
Yes |
| ai_prompt_id |
integer |
ID of the prompt |
Yes |
| id |
integer |
ID of the example |
Yes |
Response
Returns the updated example.
HTTP Response Codes
| Code |
Description |
200 OK |
Successful update |
403 Forbidden |
Your role does not allow editing |
404 Not Found |
Invalid library ID, prompt ID or example ID |
422 Unprocessable Content |
Invalid request (see response body for details) |
Delete an example.
Path Parameters
| Name |
Type |
Description |
Required |
| library_id |
integer |
ID of the library |
Yes |
| ai_prompt_id |
integer |
ID of the prompt |
Yes |
| id |
integer |
ID of the example |
Yes |
Response
(no response body)
HTTP Response Codes
| Code |
Description |
204 No Content |
Successful deletion |
403 Forbidden |
Your role does not allow editing |
404 Not Found |
Invalid library ID, prompt ID or example ID |
Stop sending the example with the prompt, keeping it. No body.
Path Parameters
| Name |
Type |
Description |
Required |
| library_id |
integer |
ID of the library |
Yes |
| ai_prompt_id |
integer |
ID of the prompt |
Yes |
| id |
integer |
ID of the example |
Yes |
Response
Returns the example, with active false.
HTTP Response Codes
| Code |
Description |
200 OK |
Successful change |
403 Forbidden |
Your role does not allow editing |
404 Not Found |
Invalid library ID, prompt ID or example ID |
Send a hidden example with the prompt again. No body.
Path Parameters
| Name |
Type |
Description |
Required |
| library_id |
integer |
ID of the library |
Yes |
| ai_prompt_id |
integer |
ID of the prompt |
Yes |
| id |
integer |
ID of the example |
Yes |
Response
Returns the example, with active true.
HTTP Response Codes
| Code |
Description |
200 OK |
Successful change |
403 Forbidden |
Your role does not allow editing |
404 Not Found |
Invalid library ID, prompt ID or example ID |
Put the examples in order in one request. An example left out keeps its position.
Path Parameters
| Name |
Type |
Description |
Required |
| library_id |
integer |
ID of the library |
Yes |
| ai_prompt_id |
integer |
ID of the prompt |
Yes |
Request Body
| Field |
Type |
Description |
Required |
| ai_search_example |
array[integer] |
Example IDs, in order |
Yes |
{ "ai_search_example": [40, 31, 35] }
Response
(no response body)
HTTP Response Codes
| Code |
Description |
200 OK |
Successful update |
403 Forbidden |
Your role does not allow editing |
404 Not Found |
Invalid library ID or prompt ID |
Have the model write requests that someone might make of the library, and run each as a search in the background. The request is answered at once; the searches appear under suggested as they finish, to be kept or thrown away.
This costs money: one call to the library’s AI provider to write the requests, and then a search for each of them, each charged to the library’s AI account as any search is.
Path Parameters
| Name |
Type |
Description |
Required |
| library_id |
integer |
ID of the library |
Yes |
| ai_prompt_id |
integer |
ID of the prompt |
Yes |
Request Body
Not wrapped, and both fields optional.
| Field |
Type |
Description |
Required |
| count |
integer |
How many requests to write (default: 12, at most 30) |
No |
| focus |
string |
Who or what the requests should be for, such as “trailer editors” |
No |
{ "count": 5, "focus": "trailer editors" }
Response
{
"searches": [
{ "id": 230, "nls": "cinematic atmospheric trailer like two steps from hell", "url": "https://app.spondulix.ai/api/v1/libraries/2/searches/230" }
]
}
HTTP Response Codes
| Code |
Description |
202 Accepted |
The requests were written and their searches are running |
403 Forbidden |
Your role does not allow editing |
404 Not Found |
Invalid library ID or prompt ID |
422 Unprocessable Content |
{ "message": "..." }: the library has no default chat model, the prompt has no current version, or the library has no tracks |
Retrieve the suggested searches that wait to be kept or thrown away. A suggestion is kept as an example with POST .../searches/{id}/save_as_example and thrown away with DELETE .../searches/{id}; either takes it off this list.
Path Parameters
| Name |
Type |
Description |
Required |
| library_id |
integer |
ID of the library |
Yes |
| ai_prompt_id |
integer |
ID of the prompt |
Yes |
Response
{
"suggestions": [
{
"search_id": 230,
"nls": "cinematic atmospheric trailer like two steps from hell",
"status": "answered",
"error_message": null,
"explanation": "This query filters for atmospheric cinematic music ...",
"total_rows": 0,
"top_titles": [],
"answer": { "explanation": "...", "query": { "filter": {}, "boost": [] } },
"url": "https://app.spondulix.ai/api/v1/libraries/2/searches/230"
}
]
}
Response Fields
| Field |
Type |
Description |
| search_id |
integer |
ID of the search the suggestion ran as |
| nls |
string |
The request the model wrote |
| status |
string |
running, answered or failed |
| error_message |
string | null |
Why it failed |
| explanation |
string | null |
The model’s account of how it read the request |
| total_rows |
integer |
Number of tracks the search found |
| top_titles |
array |
Titles of the five best matches |
| answer |
object | null |
What the model answered, which is what is kept |
| url |
string |
URL of the search |
HTTP Response Codes
| Code |
Description |
200 OK |
Successful request |
404 Not Found |
Invalid library ID or prompt ID |