Structured LLM Responses

The "types" feature of the Developer API empowers you to retrieve structured data that is validated against specific data types. With the addition of a "context_id", the API provides live, context-aware responses. Below you will find examples for each data type supported by the /v1/types/<type> endpoint.

Using the Types Endpoint

Each data type (integer, boolean, datetime, string, float, and their respective array types) can be queried through this endpoint. When making a POST request, replace <type> with the desired data type.

If you aren't passing a context ID, use the content key:

curl -X POST https://api.gethyper.ai/v1/types/boolean \
  -H "Authorization: Bearer {your_api_key}" \
  -H "Content-Type: application/json" \
  -d '{"content": "Is the earth flat?"}'

Otherwise, you should use both the query and context_id keys as in the examples below.

Integer

curl -X POST https://api.gethyper.ai/v1/types/integer \
  -H "Authorization: Bearer {your_api_key}" \
  -H "Content-Type: application/json" \
  -d '{"query": "How many employees work at the London office?", "context_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"}'

Response

Example response

{
    "data": 125
}

Boolean

curl -X POST https://api.gethyper.ai/v1/types/boolean \
  -H "Authorization: Bearer {your_api_key}" \
  -H "Content-Type: application/json" \
  -d '{"query": "Is the New York office open on Sundays?", "context_id": "b2c3d4e5-f6a7-890b-cdef-1234567890ab"}'

Response

Example response

{
    "data": false
}

Datetime

curl -X POST https://api.gethyper.ai/v1/types/datetime \
  -H "Authorization: Bearer {your_api_key}" \
  -H "Content-Type: application/json" \
  -d '{"query": "When is the next company-wide town hall meeting?", "context_id": "c3d4e5f6-a7b8-90cd-efab-2345678901cd"}'

Response

Example response

{
    "data": "2023-11-15T10:00:00Z"
}

String

curl -X POST https://api.gethyper.ai/v1/types/string \
  -H "Authorization: Bearer {your_api_key}" \
  -H "Content-Type: application/json" \
  -d '{"query": "Who is the CTO of Hyper?", "context_id": "d4e5f6a7-b8c9-0def-ab12-3456789012de"}'

Response

Example response

{
    "data": "Samir Khoja"
}

Float

curl -X POST https://api.gethyper.ai/v1/types/float \
  -H "Authorization: Bearer {your_api_key}" \
  -H "Content-Type: application/json" \
  -d '{"query": "What was the revenue growth percentage in Q2?", "context_id": "e5f6a7b8-c9d0-efab-1234-5678901234ef"}'

Response

Example response

{
    "data": 4.7
}

Integer Array

curl -X POST https://api.gethyper.ai/v1/types/integer_array \
  -H "Authorization: Bearer {your_api_key}" \
  -H "Content-Type: application/json" \
  -d '{"query": "What is the headcount for each department?", "context_id": "a1b2c3d4-e5f6-4g7h-8i9j-0k1l2m3n4o5p"}'

Response

Example response

{
  "data": [25, 40, 15, 50, 30]
}

Boolean Array

curl -X POST https://api.gethyper.ai/v1/types/boolean_array \
  -H "Authorization: Bearer {your_api_key}" \
  -H "Content-Type: application/json" \
  -d '{"query": "Are services meeting performance targets?", "context_id": "5f6a7b8c-9d0e-1f2a-3b4c-5d6e7f8g9h0i"}'

Response

Example response

{
  "data": [true, false, true, true, false]
}

Datetime Array

curl -X POST https://api.gethyper.ai/v1/types/datetime_array \
  -H "Authorization: Bearer {your_api_key}" \
  -H "Content-Type: application/json" \
  -d '{"query": "What are the upcoming project deadlines?", "context_id": "12345678-90ab-cdef-g123-456789abcdef"}'

Response

Example response

{
  "data": ["2023-11-15T17:00:00Z", "2023-12-01T17:00:00Z", "2023-12-20T17:00:00Z"]
}

String Array

curl -X POST https://api.gethyper.ai/v1/types/string_array \
  -H "Authorization: Bearer {your_api_key}" \
  -H "Content-Type: application/json" \
  -d '{"query": "List all department names", "context_id": "9a8b7c6d-5e4f-3a2b-1c0d-e9f8a7b6c5d4"}'

Response

Example response

{
  "data": ["Human Resources", "Finance", "Research and Development", "Sales", "Customer Support"]
}

Float Array

curl -X POST https://api.gethyper.ai/v1/types/float_array \
  -H "Authorization: Bearer {your_api_key}" \
  -H "Content-Type: application/json" \
  -d '{"query": "What were the customer satisfaction ratings from the last survey?", "context_id": "0f9e8d7c-6b5a-4c3d-2e1f-0a9b8c7d6e5f"}'

Response

Example response

{
  "data": [4.2, 3.8, 4.5, 4.7, 3.9]
}