AI

Generate a query

Changed on

Generate a structured Omni query from natural language using AI.

For exploratory or cross-topic questions, use Create AI job instead.

post/v1/ai/generate-query

Request

  • Base URL
    https://blobsrus.omniapp.co/api
  • URL
    https://blobsrus.omniapp.co/api/v1/ai/generate-query
  • Auth
    HTTP bearer

Request body

modelIdstring uuid required

The ID of the model to run the query against

currentTopicNamestring

Name of the base topic/table. If left empty, AI will automatically choose a topic based on the question.

promptstring

Natural language instruction describing the desired query output. If omitted, an empty prompt is sent.

workbookUrlboolean

When true, returns an Omni workbook URL that opens and runs the generated query

branchIdstring

The ID of the model branch to use to generate the query. If not provided, the main branch will be used. To retrieve branch IDs, use the List models endpoint with modelKind=BRANCH.

runQueryboolean

When true (default), the generated query is executed against the database and results are included in the response.

When false, only the generated query object is returned without executing it. Set to false to preview what query would be generated without incurring a database query.

queryAllViewsboolean

When true and the model's query_all_views_and_fields setting is enabled, allows the AI to query views that are not included in topics. If the setting is disabled, this parameter has no effect.

When both the API parameter and model setting are enabled:

  • The AI can select from any view in the model, including views not in topics
  • The AI will prefer topic-organized views unless the question clearly targets a standalone view

Note: Users with topic-locked permissions cannot use this parameter, even if the model setting is enabled.

Example request

{
  "requestedLlm": {
    "model": "claude-sonnet-5",
    "provider": "bedrock",
    "thinking": "medium"
  }
}

Response

Successfully generated query.

When your organization is over its AI credit threshold, the response also includes downgradedLlm, naming the LLM the query was generated on, and the deprecated downgradedModelTier, always haiku.

topicstring

The name of the topic used for query generation. This will be populated if the AI used a topic and null if the query was generated using a base view.

baseViewstring

The name of the base view used for query generation. This will be populated if the AI used a view outside of a topic and null if the query was generated using a topic.

downgradedLlmstring

The LLM the query was generated on, present only when your organization is over its AI credit threshold. This is the LLM Omni runs simple tasks on within your organization's LLM family.

Absent when no downgrade occurred.

downgradedModelTierstring

Deprecated. Use downgradedLlm instead, which names the specific LLM.

Present only when your organization is over its AI credit threshold. Always the literal haiku.

Absent when no downgrade occurred.

Example response

{
  "topic": "order_items",
  "baseView": "users",
  "downgradedLlm": "claude-haiku-5-5",
  "downgradedModelTier": "haiku"
}

Changes

    • breaking

      added to the request property allOf list

    • breaking

      the request property type changed from object to no type

    • warning

      removed the optional property from the response with the status

    • warning

      removed the optional property from the response with the status

    • warning

      removed the optional property from the response with the status

    • warning

      removed the optional property from the response with the status

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      the request property became optional

    • info

      the request property default value was added

    • info

      added the non-success response with the status

    • info

      added the optional property to the response with the status

    • info

      added the optional property to the response with the status

    • info

      added the required property to the response with the status

    • info

      added the required property to the response with the status

    • info

      added the required property to the response with the status

    • info

      added the required property to the response with the status