token_usage
post/api/v1beta/token_usage/estimate

Request

  • The document declares no server URL.
  • Auth: bearer_auth (a scheme the document does not define)

Request body

chat_previous_message_idstring uuid nullable

The previous message ID to anchor chat history context. Preferred over previous_message_id for new clients.

chat_provider_idstring

Optional chat provider ID to use for token estimation. If not provided, uses the default provider.

existing_chat_idstring uuid nullable

The ID of an existing chat to use. If provided, the chat with this ID will be used instead of creating a new one.

input_files_idsstring[]

The IDs of any files attached to this message. These files must already be uploaded to the file_uploads table.

new_message_contentstring nullable

Content for the new message being composed. Preferred over user_message for new clients.

previous_message_idstring uuid nullable

The ID of the message that this message is a response to. If this is the first message in the chat, this should be empty.

selected_facet_idsstring[]

IDs of facets selected by the user for this estimation.

system_promptstring nullable

Additional system prompt content to include in the estimation.

user_messagestring

The text of the message.

Example request

{
  "chat_previous_message_id": "00000000-0000-0000-0000-000000000000",
  "chat_provider_id": "gpt-4o",
  "existing_chat_id": "00000000-0000-0000-0000-000000000000",
  "new_chat": {
    "assistant_id": "00000000-0000-0000-0000-000000000000"
  },
  "new_message_content": "Hello, world!",
  "previous_message_id": "00000000-0000-0000-0000-000000000000",
  "system_prompt": "You are a concise legal assistant.",
  "user_message": "Hello, world!",
  "virtual_files": [
    {
      "content_type": "message/rfc822",
      "filename": "preview.eml"
    }
  ]
}

Response

Changes

    • 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 optional property // to the 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