mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-13 06:23:32 +00:00
docs(response_api): move file_search details to dedicated tutorial
Replace inline file_search documentation in response_api.md with a canonical link and add the new tutorial to sidebars so users discover the usage-first guide. Made-with: Cursor
This commit is contained in:
@@ -1558,132 +1558,9 @@ curl -X POST "http://localhost:4000/v1/responses" \
|
||||
|
||||
## File Search (Vector Stores)
|
||||
|
||||
The **file_search** tool lets the model search your vector stores and cite retrieved content in its answer (OpenAI Responses API format). Pass `tools=[{"type": "file_search", "vector_store_ids": [...]}]`. The response includes a `file_search_call` output item and `file_citation` annotations on the answer text.
|
||||
For full `file_search` usage (native + emulated fallback), SDK/Proxy examples, architecture diagram, and Q&A, see:
|
||||
|
||||
**Supported providers:** `openai`, `azure` (native). Other providers will receive an `UnsupportedParamsError` until the emulated-fallback path is available.
|
||||
|
||||
:::note
|
||||
If you are using LiteLLM-managed vector stores (created via `/v1/vector_stores`), pass the LiteLLM vector store ID directly — LiteLLM automatically decodes it to the provider-native ID before sending the request.
|
||||
:::
|
||||
|
||||
### Python SDK
|
||||
|
||||
```python showLineNumbers title="File search with LiteLLM Python SDK"
|
||||
import litellm
|
||||
|
||||
response = litellm.responses(
|
||||
model="openai/gpt-4.1",
|
||||
input="What is deep research?",
|
||||
tools=[{
|
||||
"type": "file_search",
|
||||
"vector_store_ids": ["vs_abc123"] # native or LiteLLM-managed vector store ID
|
||||
}],
|
||||
)
|
||||
|
||||
# Output contains a file_search_call item followed by the answer with citations
|
||||
for item in response.output:
|
||||
if item.type == "file_search_call":
|
||||
print("Queries:", item.queries)
|
||||
elif item.type == "message":
|
||||
for block in item.content:
|
||||
print(block.text)
|
||||
for ann in block.annotations:
|
||||
print(f" ↳ {ann.filename} (file_id={ann.file_id})")
|
||||
```
|
||||
|
||||
#### Response Format
|
||||
|
||||
```json
|
||||
{
|
||||
"output": [
|
||||
{
|
||||
"type": "file_search_call",
|
||||
"id": "fs_67c09ccea8c48191ade9367e3ba71515",
|
||||
"status": "completed",
|
||||
"queries": ["What is deep research?"],
|
||||
"search_results": null
|
||||
},
|
||||
{
|
||||
"id": "msg_67c09cd3091c819185af2be5d13d87de",
|
||||
"type": "message",
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
{
|
||||
"type": "output_text",
|
||||
"text": "Deep research is a capability that allows for extensive inquiry ...",
|
||||
"annotations": [
|
||||
{
|
||||
"type": "file_citation",
|
||||
"index": 992,
|
||||
"file_id": "file-2dtbBZdjtDKS8eqWxqbgDi",
|
||||
"filename": "deep_research_blog.pdf"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### LiteLLM Proxy (AI Gateway)
|
||||
|
||||
**OpenAI Python SDK (proxy as base_url):**
|
||||
|
||||
```python showLineNumbers title="File search via LiteLLM Proxy"
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI(
|
||||
base_url="http://localhost:4000",
|
||||
api_key="your-proxy-api-key",
|
||||
)
|
||||
|
||||
response = client.responses.create(
|
||||
model="openai/gpt-4.1",
|
||||
input="Summarise the Q3 earnings report.",
|
||||
tools=[{
|
||||
"type": "file_search",
|
||||
"vector_store_ids": ["vs_abc123"]
|
||||
}],
|
||||
)
|
||||
```
|
||||
|
||||
**curl:**
|
||||
|
||||
```bash title="File search via curl to LiteLLM Proxy"
|
||||
curl -X POST "http://localhost:4000/v1/responses" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer your-proxy-api-key" \
|
||||
-d '{
|
||||
"model": "openai/gpt-4.1",
|
||||
"input": "Summarise the Q3 earnings report.",
|
||||
"tools": [{"type": "file_search", "vector_store_ids": ["vs_abc123"]}]
|
||||
}'
|
||||
```
|
||||
|
||||
### Using LiteLLM-Managed Vector Stores
|
||||
|
||||
If you created a vector store through LiteLLM (`POST /v1/vector_stores/new`), use the returned `vector_store_id` directly. LiteLLM decodes the unified ID to the provider-native vector store ID automatically.
|
||||
|
||||
```python showLineNumbers title="File search with LiteLLM-managed vector store"
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI(base_url="http://localhost:4000", api_key="your-proxy-api-key")
|
||||
|
||||
# vector_store_id returned by POST /v1/vector_stores/new
|
||||
managed_vs_id = "bGl0ZWxsbV9wcm94eTo..." # LiteLLM-managed ID
|
||||
|
||||
response = client.responses.create(
|
||||
model="openai/gpt-4.1",
|
||||
input="What does the documentation say about authentication?",
|
||||
tools=[{"type": "file_search", "vector_store_ids": [managed_vs_id]}],
|
||||
)
|
||||
```
|
||||
|
||||
LiteLLM will:
|
||||
1. Verify the calling team has access to the vector store.
|
||||
2. Decode the managed ID to the provider-native vector store ID.
|
||||
3. Forward the request to the provider unchanged.
|
||||
- [`File Search in the Responses API — E2E Testing Guide`](/docs/tutorials/file_search_responses_api)
|
||||
|
||||
## Session Management
|
||||
|
||||
|
||||
@@ -1054,6 +1054,7 @@ const sidebars = {
|
||||
label: "AI Coding Tools (OpenWebUI, Claude Code, Gemini CLI, OpenAI Codex, etc.)",
|
||||
href: "/docs/ai_tools",
|
||||
},
|
||||
"tutorials/file_search_responses_api",
|
||||
"tutorials/anthropic_file_usage",
|
||||
"tutorials/default_team_self_serve",
|
||||
"tutorials/msft_sso",
|
||||
|
||||
Reference in New Issue
Block a user