> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge-base server tools

> List and query knowledge bases from the Responses API so a model can answer from workspace documents.

Two server tools give a model access to knowledge bases in the current workspace:

* `retrieve_knowledge_bases` lists available knowledge bases and their keys.
* `query_knowledge_base` retrieves document content from one knowledge base.

Knowledge-base server tools are currently supported on the Responses API. Use both tools when the knowledge-base key is not already known.

## Quick start

The examples use the client configuration from the [Server tools overview](/docs/ai-gateway/features/server-tools).

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST https://api.orq.ai/v3/router/responses \
    -H "Authorization: Bearer $ORQ_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "openai/gpt-5.4-mini",
      "input": "What is the refund policy in the support knowledge base?",
      "tools": [
        { "type": "retrieve_knowledge_bases" },
        { "type": "query_knowledge_base" }
      ]
    }'
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const response = await client.responses.create({
    model: 'openai/gpt-5.4-mini',
    input: 'What is the refund policy in the support knowledge base?',
    tools: [
      { type: 'retrieve_knowledge_bases' },
      { type: 'query_knowledge_base' },
    ] as any,
  });

  console.log(response.output_text);
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  response = client.responses.create(
      model="openai/gpt-5.4-mini",
      input="What is the refund policy in the support knowledge base?",
      tools=[
          {"type": "retrieve_knowledge_bases"},
          {"type": "query_knowledge_base"},
      ],
  )

  print(response.output_text)
  ```
</CodeGroup>

## How retrieval works

1. `retrieve_knowledge_bases` returns knowledge-base keys and, when requested by the model, their descriptions.
2. The model selects a key and calls `query_knowledge_base` with a search query.
3. The query tool returns matching document content to the model.

The list tool returns metadata, not document content. A model must call the query tool before it can answer from a knowledge base.

## Model-supplied arguments

The tool entries have no configuration fields beyond `type`. The model supplies these arguments when it calls them:

| Tool                       | Argument               | Type    | Description                                     |
| -------------------------- | ---------------------- | ------- | ----------------------------------------------- |
| `retrieve_knowledge_bases` | `include_descriptions` | boolean | Include the description of each knowledge base. |
| `query_knowledge_base`     | `query`                | string  | Search query.                                   |
| `query_knowledge_base`     | `knowledge_base_key`   | string  | Key returned by `retrieve_knowledge_bases`.     |
| `query_knowledge_base`     | `include_metadata`     | boolean | Include document metadata with the results.     |

Knowledge-base calls are not included in `usage.server_tool_use`.
