---
title: "Text-to-SQL Context (NSQL)"
method: GET
path: "/v1/nsql/context"
tags: ["SQL"]
---

# Text-to-SQL Context (NSQL)

`GET /v1/nsql/context`

Return the same context block that `/v1/nsql` injects into the configured NSQL model.

The response is a markdown/plain-text block or JSON object containing the in-scope datasets, schemas,
Spice-specific SQL functions, registered user-defined functions, relevant JSON/Spark compatibility functions,
and optional sample data.

## Query parameters

- `model` string
- `include_sampling` boolean
- `sampling_limit` integer
- `include_examples` boolean
- `examples_limit` integer
- `datasets` string[]

## Headers

- `Accept` string, required

## Response `200`

NSQL context block

- NsqlContextJsonResponse
  - `context` string, required — The rendered NSQL context block injected into `/v1/nsql` model requests.
  - `datasets` NsqlDatasetContext[], required — In-scope datasets with schema, metadata, relationship, key, and index details.
    - `catalog` string, nullable
    - `columns` NsqlColumnContext[], required
      - `data_type` string, required
      - `description` string, nullable
      - `full_text_search` boolean, required
      - `indexed` boolean, required
      - `metadata` object, required
      - `name` string, required
      - `nullable` boolean, required
      - `primary_key` boolean, required
      - `source_type` string, nullable
      - `unique` boolean, required
      - `vector_search` boolean, required
    - `description` string, nullable
    - `foreign_keys` NsqlForeignKeyContext[], required
      - `columns` string[], required
      - `foreign_columns` string[], required
      - `foreign_table` string, required
    - `indexes` NsqlIndexContext[], required
      - `columns` string[], required
      - `kind` string, required
      - `name` string, nullable
      - `source` string, required
    - `metadata` object, required
    - `name` string, required
    - `primary_key` string[], required
    - `schema` string, nullable
    - `search` NsqlDatasetSearchContext, required
      - `full_text` NsqlFullTextSearchContext[], required
        - `column` string, required
        - `engine` string, required
        - `function` string, required
        - `index` NsqlIndexContext
          - `columns` string[], required
          - `kind` string, required
          - `name` string, nullable
          - `source` string, required
        - `index_store` string, required
        - `notes` string[], required
        - `required_columns` string[], required
        - `row_id_columns` string[], required
        - `syntax` string, required
      - `vector` NsqlVectorSearchContext[], required
        - `chunked` boolean, required
        - `column` string, required
        - `engine` string, nullable
        - `function` string, required
        - `index` NsqlIndexContext
          - `columns` string[], required
          - `kind` string, required
          - `name` string, nullable
          - `source` string, required
        - `input_mode` string, nullable
        - `model` string, required
        - `notes` string[], required
        - `required_columns` string[], required
        - `row_id_columns` string[], required
        - `syntax` string, required
        - `vector_size` integer, nullable
    - `table` string, required
    - `unique_constraints` array[], required
      - string[]
  - `functions` NsqlFunctionContext, required
    - `additional` NsqlFunctionContextEntry[], required
      - `description` string, nullable
      - `example` string, nullable
      - `function_type` string, nullable
      - `name` string, required
      - `signatures` string[]
      - `syntax` string, nullable
    - `json` NsqlFunctionContextEntry[], required
      - `description` string, nullable
      - `example` string, nullable
      - `function_type` string, nullable
      - `name` string, required
      - `signatures` string[]
      - `syntax` string, nullable
    - `search` NsqlFunctionContextEntry[], required
      - `description` string, nullable
      - `example` string, nullable
      - `function_type` string, nullable
      - `name` string, required
      - `signatures` string[]
      - `syntax` string, nullable
    - `spark_compatibility` NsqlSparkFunctionContext, required
      - `description` string, required
      - `functions` string[], required
    - `summary` string, required
    - `user_defined` UserFunctionContextEntry[], required
      - `description` string, nullable
      - `from` string, required
      - `kind` string, required
      - `name` string, required
      - `syntax` string, nullable
      - `volatility` string, required
  - `instructions` string[], required — High-level SQL generation instructions.
  - `samples` SampleContextBlock[], required — Optional sample blocks included when requested.
    - `content` string, required
    - `title` string, required
  - `sql` NsqlSqlContext, required
    - `dialect` string, required
    - `engine` string, required
    - `notes` string[], required
    - `parser` string, required
    - `version` string, required

## Other responses

- `400` — Invalid request parameters
- `406` — Requested response content type is not available
- `500` — Internal server error

---

[API](https://skmtc.dev/spiceai/apis/runtime.md) · [All operations](https://skmtc.dev/spiceai/apis/runtime/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/spiceai/runtime/revisions/fb597a4eaa56/schema)
