context

Search context and generate an LLM-powered answer

Changed on

This endpoint performs a context search using the context processor, joins all matching context chunks into a single string, then sends that joined context along with the user's query to an LLM to produce a natural-language answer grounded in the retrieved context.

By default the response only includes the generated answer. Pass ?context=true to also receive the joined context string that was used to ground the answer.

post/api/v1/context/search/steer

Request

Query parameters

mode'fast' | 'standard'

Controls the search mode:

  • mode=fast -> prioritizes speed over completeness.
  • mode=standard -> performs a comprehensive search (default if omitted).
contextboolean

When set to true, the response includes the joined context string used to ground the answer. Defaults to false (only answer,and usage are returned).

Request body

user_idstring

The ID of the user making the request

steeringPromptstring

The steering prompt for the query - basically the way in which you want to get your answer as.

querystring required

The search query and question to be answered using retrieved context

similarity_thresholdnumber required

Maximum similarity threshold (must be >= minimum_similarity_threshold)

minimum_similarity_thresholdnumber required

Minimum similarity threshold

scope'internal' | 'external'

Search scope

magic_keystring nullable

Magic key (sk_context_share_...) to search within contexts shared with the caller

Example request

{
  "user_id": "user123",
  "steeringPrompt": "Return only the basic details of the person in a structured JSON schema with the fields \"name\", \"status\", \"location\"",
  "query": "What did the customer ask about pricing for the Scale plan?",
  "similarity_threshold": 0.8,
  "minimum_similarity_threshold": 0.5,
  "body_metadata": {
    "fileName": "support_thread_TCK-1234.txt",
    "lastModifiedAt": "2025-01-10T12:34:56.000Z"
  },
  "magic_key": "sk_context_share_nC0KUEF9T6UGDHYVUiMU"
}

Response

Successfully retrieved context and generated an answer.

answerstring required

The LLM-generated answer based on the retrieved context

contextstring

The joined context retrieved from the context processor. Only present when the request was made with ?context=true.

Changes

    • breaking

      removed the required property from the response with the status

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property

    • info

      added the required property to the response with the status