RAG overview

Prev Next

Available in VPC

Retrieval Augmented Generation (RAG) is a NAVER Cloud Platform service that allows LLM to generate customized answers with high accuracy by referencing user data. The RAG service provides APIs for generating answers to questions and retrieving, editing, and deleting documents and files referenced in the answer generation in RESTful form.

API key

The RAG API issues an API key, a user identification tool, to each account so that only authorized users can call it. The API key is used as a parameter in the request header that is passed as authentication information when calling the API. Therefore, to use the RAG API, you must first obtain an API key.

Issue API key

API keys can be issued in RAG of the NAVER Cloud Platform console. The following describes how to issue them.

  1. In the NAVER Cloud Platform console, click Services > AI Services > RAG > Services menus, in that order.
  2. Click the [Manage API key] button in the service table.
  3. When the Manage API key pop-up window appears, click the [Issue API key] button.
  4. When the Issue API key pop-up window appears, click the [Issue] button.
    • In the Copy API key pop-up window, copy the issued API key.
Caution

The issued API key cannot be verified after the Copy API key pop-up window is closed. Therefore, be sure to store it in a separate safe space at the time of issuance.

Note

You can create up to 5 API keys based on the main account of the NAVER Cloud Platform.

Set API security

If the API key is leaked to a third party, security issues may arise, such as unauthorized use of RAG resources, so proper preparation and response are required.

Delete and reissue API key

If you do not use the API key or suspect that it has been stolen by a third party, you must delete the issued API key and reissue it. The following describes how to delete and reissue the API key.

  1. In the NAVER Cloud Platform console, click Services > AI Services > RAG menus, in that order.
  2. Click the [Manage API key] button in the service table.
  3. When the Manage API key page appears, click rag-more-icon of the API key to delete, and then click the Delete menu.
  4. When the Delete API key pop-up window appears, click the [Delete] button.
  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

The following describes commonly used request and response formats in 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, then 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 defines the API call failure information. The following describes responseError.

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 Too large file error
400 40001 Service not ready Conversation attempted while indexing is not complete
  • Initial: testable after indexing
  • Incremental indexing: testable without indexing
400 40002 Invalid service id Invalid service ID
401 200 Authentication failed Authentication failed
403 210 Permission denied Unauthorized
404 404 Index or document not found No index or documentation found
404 1001 Document not found No documentation found
404 40401 Service ID not found Non-existent service ID
408 40800 Timeout Timeout
408 40801 Llm timeout. LLM 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 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 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 Crashes
504 510 Gateway timeout Gateway timeout

Response example

For response examples when a call is successful, see each API specification. The following is a sample response upon a failed call.

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

RAG API

The following describes the APIs provided by the RAG service.

Chats

API Description
Create conversation LLM generates interactive sentences for user queries.
Create conversation title LLM generates titles for conversations with users.

Documents

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.

Files

API Description
Add file Upload an indexing system file.
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

NAVER Cloud Platform provides a variety of related resources to help users better understand RAG APIs.

  • RAG service guides
    • User Guide{target="_blank"}: how to use RAG in the NAVER Cloud Platform console
    • Ncloud use environment guide: guide on VPC and Classic environments and supported features