RAG overview

Prev Next

Available in VPC

RAG (Retrieval Augmented Generation) is a NAVER Cloud Platform service that enables LLMs to generate accurate, customized answers by referencing your data. The RAG API provides RESTful endpoints for generating answers to questions and managing the documents and files used as reference sources.

API key

The RAG API authenticates requests using API keys. Each account is issued a unique key, which must be included in the request header when calling the API. Therefore, to use the RAG API, you must first obtain an API key.

Issue API key

You can issue API keys from the NAVER Cloud Platform console. To issue them:

  1. In the NAVER Cloud Platform console, navigate to Menu > Services > AI Services > RAG > Services.
  2. Click [Manage API key] in the service table.
  3. In the Manage API key page, click [Issue API key].
  4. In the Issue API key popup, click [Issue].
    • In the Copy API key popup, copy the issued API key.
Caution

The issued API key cannot be viewed after the Copy API key popup is closed. Save your API key in a secure location immediately after it is issued.

Note

You can create up to 5 API keys per NAVER Cloud Platform main account.

Set API security

If an API key is compromised, unauthorized parties could access your RAG resources. Take the following precautions to protect your keys.

Delete and reissue API key

If you no longer use an API key or suspect it has been compromised, delete it and issue a new one. To delete and reissue an API key:

  1. In the NAVER Cloud Platform console, navigate to Menu > Services > AI Services > RAG.
  2. Click [Manage API key] in the service table.
  3. In the Manage API key page, click rag-more-icon of the API key to delete, and then click Delete.
  4. In the Delete API key popup, click [Delete].
  5. See Issue API key and issue a new API key.
Caution

Deleted API keys are recognized as invalid keys and can no longer be used for API calls.

Common RAG settings

This section covers the request and response formats used across RAG APIs.

Request

The following describes the common request format:

API URL

The request API URL is as follows:

https://kr-pub-gateway.rag.naverncp.com

Request headers

The following describes the request headers:

Field Required Description
Authorization Required API key for authentication
  • Bearer {apiKey}
Content-Type Required Request data format
  • application/json | multipart/form-data
Accept Optional Response data format
  • text/event-stream
Note
  • Response results are returned in JSON by default, but if you specify Accept as text/event-stream, the response results are returned as a stream.

Response

The following describes the common response format:

Response body

The response body includes the following data:

responseError
responseError contains details about a failed API call. The following describes the responseError fields:

Field Type Required Description
code String Required Error code
message String Required Error message

Response status codes

The following describes the response status codes:

HTTP status code Code Message Description
200 20000 Success Request succeeded.
400 400 Bad Request File error.
400 40000 Invalid parameters Header parameter error.
400 40000 Too large file error File size exceeds the limit.
400 40001 Service not ready Conversation attempted while indexing is not complete.
  • Initial indexing: Testing available after indexing is complete.
  • Incremental indexing: Testing available even before indexing is complete.
400 40002 Invalid service id Invalid service ID.
401 200 Authentication failed Authentication failed.
403 210 Permission denied Permission denied.
404 404 Index or document not found Index or document not found.
404 1001 Document not found Document not found.
404 40401 Service ID not found Service ID does not exist.
408 40800 Timeout Timeout.
408 40801 Llm timeout LLM timeout.
408 40802 Retrieval timeout Retrieval timeout.
408 40803 Citation timeout Citation timeout.
415 41500 Unsupported file type error Unsupported file format.
422 42200 Request validation error Request body error.
422 422 Request Validation Error Request parameter error.
500 900 Unexpected Error Unexpected error.
500 50000 Extract error Extraction error.
500 50001 Llm error LLM response error.
500 50002 Text too long LLM maximum token count exceeded.
500 50003 Too many requests LLM request limit per unit time exceeded.
500 50004 Llm request failed LLM request failed.
500 50005 Llm model not found Model type not supported.
500 50006 Client exception Internal error.
500 50007 Invalid Key Invalid API key.
500 50008 Model not found LLM model name not found.
500 50009 Quota Exceeded LLM usage limit exceeded. Credit recharge required.
500 50020 Retrieval error Search error.
500 50100 Citation error Citation generation error.
503 500 Service unavailable Service temporarily unavailable.
503 520 Unavailable endpoint domain Service temporarily unavailable.
503 530 Connection closed by endpoint Connection terminated abnormally.
504 510 Gateway timeout Gateway timeout.

Response example

For successful response examples, see each API's specification page. The following shows a sample error response:

{
    "code": 50008,
    "message": "Model not found"
}

RAG APIs

This section describes the APIs provided by RAG.

Chat

The following describes the Chat-related APIs:

API Description
Create conversation Generate an LLM response to a user query.
Create conversation title Generate a title for a conversation using the LLM.

Document

The following describes the Document-related APIs:

API Description
Add document Upload JSON data to the indexing system.
Add document by specifying ID Upload JSON data to the indexing system by specifying a document ID.
Replace document Replace a previously uploaded document with a new one.
Delete documents Delete an existing uploaded document.
Get indexed document Get indexed documents in the service.
Get indexed document count Get the number of indexed documents in the service.
Get document index status Get the processing status of a document requested for indexing.

File

The following describes the File-related APIs:

API Description
Add file Upload a file to the indexing system.
Add file by specifying ID Upload a file to the indexing system by specifying a file ID.
Replace file Replace a previously uploaded file with a new one.
Delete file Delete an existing uploaded file.

RAG related resources

These resources provide additional context and support for RAG APIs.