Documentation
API Reference
Playground
Chat completionsResponsesSystem One
Document classificationEmbeddings

Studio API

Upload fileList filesRetrieve fileDelete file
Create jobRetrieve job

Search

Create vector storeList vector storesRetrieve vector storeModify vector storeDelete vector storeAdd file to vector storeList files in vector storeRetrieve file in vector storeRemove file from vector storeCreate file batchRetrieve file batchList files in file batchCancel file batchSearch vector store
Create response

Create response

Generate an AI response grounded in your documents. Retrieves relevant chunks from the specified vector stores and uses them as context for the LLM (Retrieval-Augmented Generation).

POST
/responses
/responses

The Authorization access token

input*

tools*
array

Authorization

Authorization
Required
Bearer <token>

In: header

Request Body

application/jsonRequired

modelstring

The model to use for generating the response.

Default: "solar-pro4"

input
Required
string | array<object>

The user's question or input.

tools
Required
array<object>

List of tools. Use the file_search type for RAG.

streamboolean

Enable streaming for real-time responses.

Default: false

instructionsstring

System instructions to guide the LLM's behavior.


Example

Non-streaming request

curl -X POST https://api.upstage.ai/v2/responses \
  -H "Authorization: Bearer $UPSTAGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "solar-pro4",
    "input": "What are the key features?",
    "tools": [
      {
        "type": "file_search",
        "vector_store_ids": ["vs_abc123def456"],
        "max_num_results": 5
      }
    ]
  }'

Non-streaming response

{
  "id": "resp_abc123",
  "object": "response",
  "created_at": 1711645000,
  "model": "solar-pro4",
  "output": [
    {
      "type": "file_search_call",
      "id": "fs_call_001",
      "status": "completed",
      "queries": ["What are the key features?"],
      "results": [
        {
          "file_id": "file_xyz789",
          "filename": "features.pdf",
          "text": "The key features include...",
          "score": 0.95,
          "attributes": {}
        }
      ]
    },
    {
      "type": "message",
      "id": "msg_001",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Based on the documents, the key features are...",
          "annotations": []
        }
      ]
    }
  ]
}

Streaming request

Set stream=True to receive Server-Sent Events (SSE) in real-time.

curl -X POST https://api.upstage.ai/v2/responses \
  -H "Authorization: Bearer $UPSTAGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "solar-pro4",
    "input": "Summarize the document.",
    "tools": [
      {
        "type": "file_search",
        "vector_store_ids": ["vs_abc123def456"]
      }
    ],
    "stream": true
  }'

SSE event types

EventDescription
response.createdResponse object created.
file_search_call.searchingFile search is in progress.
file_search_call.completedFile search completed with results.
output_text.deltaIncremental text chunk from the LLM.
output_text.doneLLM text generation completed.
response.completedFull response completed.
[DONE]Final signal indicating the stream has ended.

Search vector store

Run a natural-language query against a vector store. Covers the request body (query, max_num_results, filters), the search results page object (data with file_id, filename, score, content; has_more, next_page), example request and response, and a note on multi-query requests.

On this page

Create responseExampleNon-streaming requestNon-streaming responseStreaming requestSSE event types