Skip to content

Commit 62b0334

Browse files
Michael IrvineMichael Irvine
authored andcommitted
updates AI API reference
1 parent deeb5e2 commit 62b0334

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/pages/reference/ai-api.mdx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,21 @@ Generate a Cube query that can be used to answer a user's question, and (optiona
1111
| `messages` | ✅ Yes | An array of messages in the format: `{ "role": "user" \| "assistant", "content": "string" }` |
1212
| `views` | | An array of view names (used to limit the views that the AI API can use to generate its answer) |
1313
| `runQuery` | | Boolean (true or false) whether to run the query and return its results |
14+
| `options` | | An object in the format `{ "chart": true \| false }`
1415

1516
Response
1617

1718
- `message` - A message from the AI assistant describing the query, how it was chosen, why it could not generate the requested query, etc.
1819
- `cube_query` - A Cube [Query](/product/apis-integrations/rest-api/query-format) that could be used to answer the given question
20+
- `chart` - If the `chart` option is set to `true`, an object containing a chart spec for the generated query in the following format:
21+
```json
22+
{
23+
"type": "bar" | "line" | "pie" | "table" | "area" | "scatter",
24+
"x": string,
25+
"y": string[],
26+
"pivot": string // optional; the field to pivot by, if any
27+
}
28+
```
1929

2030
### Examples
2131

@@ -28,7 +38,7 @@ curl \
2838
-X POST \
2939
-H "Content-Type: application/json" \
3040
-H "Authorization: EXAMPLE-API-TOKEN" \
31-
--data '{ "messages": [{ "role": "user", "content": "What cities have the highest aov this year?" }]}' \
41+
--data '{ "messages": [{ "role": "user", "content": "What cities have the highest aov this year?", "views": ["orders_view"] }]}' \
3242
https://YOUR_CUBE_API/cubejs-api/v1/ai/query/completions
3343
```
3444

0 commit comments

Comments
 (0)