Generative AI Cloud (SaaS) チャットUI用API (1.0)

Download OpenAPI specification:

一般対話API

指定されたチャット会話に対する、LLMからの応答を作成し返却するAPI。また会話の履歴を保持し、過去の会話履歴を考慮した対話が可能。historyIdを指定することで複数の履歴を保持することができる。また、システム連携向けに会話の履歴を使用・保存しない単発の会話の指定も可能(oneshotオプション)。テンプレート対話、検索対話からの履歴を含めた対話にも対応する。

Authorizations:
bearerAuth
header Parameters
Content-Type
required
string

application/json を固定で指定

x-nec-genai-client-id
required
string

APIの使用者を特定するためのID。呼び出し元側でユーザIDなど一意なIDを指定する必要がある(メールアドレス推奨)。API側では会話履歴などのリソースへのアクセス制御などに使用される

x-nec-genai-api-version
string

APIのバージョン。現時点では使用していない(将来使用する可能性あり)

Request Body schema: application/json
required
userContent
required
string (userContent)

ユーザプロンプトのContent文字列

systemContent
string (systemContent)

システムプロンプトのContent文字列。systemTemplateIdと両方指定されている場合、systemContentの値が優先される。

historyId
required
string (historyId)

参照する履歴ID。指定が「new」場合は新しい会話履歴とする。oneshotがtrueの場合のみ指定不要。履歴IDを指定する場合はuuidかhistory_である必要がある

oneshot
boolean (oneshot)
Default: false

trueを指定することで履歴を使用せず単発での対話が可能(履歴にも保存されません)

model
required
string (model)

LLMのモデル名

stream
boolean (stream)
Default: false

LLMの応答をstreaming形式で返却するかどうか

streamNum
integer (streamNum)
Default: 10

streamingがtrueの場合に何文字単位で返却するかを指定(範囲1-1000)

maxTokens
integer (maxTokens)
Default: 1024

LLMのトークンの最大値(範囲:1~8192)

temperature
number (temperature)
Default: 1

LLMのランダム性パラメータ。0に近いほど最も確率が高い回答が選ばれる

Responses

Request samples

Content type
application/json
{
  • "userContent": "こんにちは",
  • "systemContent": "あなたはAIアシスタントです",
  • "historyId": "new",
  • "oneshot": false,
  • "model": "cotomi-fast-v2.0",
  • "stream": false,
  • "streamNum": 1,
  • "maxTokens": 1024,
  • "temperature": 1
}

Response samples

Content type
application/json
{
  • "error": {
    },
  • "answer": "こんにちは、何かお手伝いすることはありますか?",
  • "historyId": "history_12345678-90ab-cdef-ghij-zzz"
}

検索対話API

事前に登録された文書に対するRAGを行うAPI。履歴機能には対応しない(履歴IDは新規採番のみ対応(履歴を使いたい場合は一般対話を利用する)。既定は履歴は採番しない)

Authorizations:
bearerAuth
header Parameters
Content-Type
required
string

application/json を固定で指定

x-nec-genai-client-id
required
string

APIの使用者を特定するためのID。呼び出し元側でユーザIDなど一意なIDを指定する必要がある(メールアドレス推奨)。API側では会話履歴などのリソースへのアクセス制御などに使用される

x-nec-genai-api-version
string

APIのバージョン。現時点では使用していない(将来使用する可能性あり)

Request Body schema: application/json
required
userContent
required
string (userContent)

ユーザプロンプトのContent文字列(検索したい内容を記載)

templateId
string (templateId)
Default: "search"

検索用テンプレートID。指定しない場合は既定値を使用する

vectorIndex
required
string (vectorIndex)

追加情報(ベクトルストアのIndex名)

object (searchOption)

ベクトル検索のオプションをJson形式で必要に応じて複数記載する。

oneshot
boolean (oneshot)
Default: true

trueを指定することで履歴を使用せず単発での対話が可能(履歴にも保存されません)。falseを指定すると、履歴IDが採番され、一般対話で会話を継続することができます。

model
required
string (model)

LLMのモデル名

stream
boolean (stream)
Default: false

LLMの応答をstreaming形式で返却するかどうか

streamNum
integer (streamNum)
Default: 10

streamingがtrueの場合に何文字単位で返却するかを指定(範囲1-1000)

maxTokens
integer (maxTokens)
Default: 1024

LLMのトークンの最大値

temperature
number (temperature)
Default: 1

LLMのランダム性パラメータ。0に近いほど最も確率が高い回答が選ばれる

Responses

Request samples

Content type
application/json
{
  • "userContent": "こんにちは",
  • "templateId": "search",
  • "vectorIndex": "test-index",
  • "searchOption": {
    },
  • "oneshot": true,
  • "model": "cotomi-fast-v2.0",
  • "stream": false,
  • "streamNum": 1,
  • "maxTokens": 1024,
  • "temperature": 1
}

Response samples

Content type
application/json
{
  • "error": {
    },
  • "answer": "Generative AI APIサービスは...",
  • "historyId": "history_12345678-90ab-cdef-ghij-zzz",
  • "sourceDocuments": [
    ]
}

テンプレート対話API

テンプレートプロンプトに任意のパラメータを埋め込み、パラメータを置換することでLLMと対話するAPI。

Authorizations:
bearerAuth
header Parameters
Content-Type
required
string

application/json を固定で指定

x-nec-genai-client-id
required
string

APIの使用者を特定するためのID。呼び出し元側でユーザIDなど一意なIDを指定する必要がある(メールアドレス推奨)。API側では会話履歴などのリソースへのアクセス制御などに使用される

x-nec-genai-referred-templateid
required
string

使用したテンプレートIDを指定する

x-nec-genai-api-version
string

APIのバージョン。現時点では使用していない(将来使用する可能性あり)

Request Body schema: application/json
required
userContent
required
string (userContent)

置換する文字列を指定

templateId
required
string (templateId)

テンプレートID。Generative AI API管理ポータルのテンプレート画面から使用したいテンプレートのIDをコピーして指定してください。

oneshot
boolean (oneshot)
Default: true

trueを指定することで履歴を使用せず単発での対話が可能(履歴にも保存されません)。falseを指定すると、履歴IDが採番され、一般対話で会話を継続することができます。

model
required
string (model)

LLMのモデル名

stream
boolean (stream)
Default: false

LLMの応答をstreaming形式で返却するかどうか

streamNum
integer (streamNum)
Default: 10

streamingがtrueの場合に何文字単位で返却するかを指定(範囲1-1000)

maxTokens
integer (maxTokens)
Default: 1024

LLMのトークンの最大値

temperature
number (temperature)
Default: 1

LLMのランダム性パラメータ。0に近いほど最も確率が高い回答が選ばれる

Responses

Request samples

Content type
application/json
{
  • "userContent": "私は学生です",
  • "templateId": "summary",
  • "oneshot": true,
  • "model": "cotomi-fast-v2.0",
  • "stream": true,
  • "streamNum": 3,
  • "maxTokens": 1024,
  • "temperature": 1
}

Response samples

Content type
application/json
{
  • "error": {
    },
  • "answer": "こんにちは、何かお手伝いすることはありますか?",
  • "historyId": "history_12345678-90ab-cdef-ghij-zzz"
}

拡張対話API

一般対話APIに添付ファイルもしくはWebコンテンツ(URL)の内容に対する対話を実施する機能を追加。(以降、添付ファイルに対する対話を「ファイル解析機能」、Webコンテンツに対する対話を「URL解析機能」と記載)

Authorizations:
bearerAuth
header Parameters
Content-Type
required
string

application/json を固定で指定

x-nec-genai-client-id
required
string

APIの使用者を特定するためのID。呼び出し元側でユーザIDなど一意なIDを指定する必要がある(UUID 4推奨)。API側では会話履歴などのリソースへのアクセス制御などに使用される

x-nec-genai-api-version
string

APIのバージョン。現時点では使用していない(将来使用する可能性あり)

Request Body schema: application/json
required
userContent
required
string (userContent)

ユーザプロンプトのContent文字列

systemContent
string (systemContent)

システムプロンプトのContent文字列。systemTemplateIdと両方指定されている場合、systemContentの値が優先される。

historyId
string (historyId)

参照する履歴ID。指定が「new」場合は新しい会話履歴とする。oneshotがtrueの場合のみ指定不要。履歴IDを指定する場合はuuidかhistory_uuidである必要がある。

oneshot
boolean (oneshot)
Default: false

trueを指定することで履歴を使用せず単発での対話が可能(履歴にも保存されません)。

model
required
string (model)

LLMのモデル名

stream
boolean (stream)
Default: false

LLMの応答をstreaming形式で返却するかどうか

streamNum
integer (streamNum)
Default: 10

streamingがtrueの場合に何文字単位で返却するかを指定(範囲1-1000)

maxTokens
integer (maxTokens)
Default: 1024

LLMのトークンの最大値

temperature
number (temperature)
Default: 1

LLMのランダム性パラメータ。0に近いほど最も確率が高い回答が選ばれる

object (addContent)

addContentsに移行したため、本パラメータは非推奨。ファイル解析機能、URL解析機能を用いる場合指定する。addContentとaddContentsの両方がリクエストパラメータに含まれていた場合、addContentsの値が優先される。

Array of objects (addContents)

ファイル解析機能、URL解析機能を用いる場合指定する。addContentとaddContentsの両方がリクエストパラメータに含まれていた場合、addContentsの値が優先される。

Responses

Request samples

Content type
application/json
{
  • "userContent": "要約してください",
  • "systemContent": "あなたはAIアシスタントです",
  • "historyId": "new",
  • "oneshot": false,
  • "model": "cotomi-fast-v2.0",
  • "stream": true,
  • "streamNum": 1,
  • "maxTokens": 1024,
  • "temperature": 1,
  • "addContent": {
    },
  • "addContents": [
    ]
}

Response samples

Content type
application/json
{
  • "answer": "Generative AI APIサービスは...",
  • "historyId": "history_12345678-90ab-cdef-ghij-zzz",
  • "sourceDocuments": [
    ]
}

ユーザの履歴一覧を取得

ユーザID、ユーザID×機能単位での履歴の一覧を取得する。あくまでも一覧情報のみの取得であり、会話履歴の具体的な内容は履歴取得で行う。

ユーザIDはHTTPヘッダー(x-nec-genai-client-id)が必須。ユーザIDに紐づいた履歴を取得する。

タイトルは初回対話時のuserContentの先頭数文字を設定する

Authorizations:
bearerAuth
path Parameters
maxnum
required
integer

最大取得件数(範囲:1~100)

header Parameters
Content-Type
required
string

application/json を固定で指定

x-nec-genai-client-id
required
string

APIの使用者を特定するためのID。呼び出し元側でユーザIDなど一意なIDを指定する必要がある(メールアドレス推奨)。API側では会話履歴などのリソースへのアクセス制御などに使用される

x-nec-genai-api-version
string

APIのバージョン。現時点では使用していない(将来使用する可能性あり)

Responses

Response samples

Content type
application/json
{
  • "error": {
    },
  • "historyList": [
    ]
}

一連の会話履歴の内容を取得

一連の会話履歴の内容の取得を行う。全ての会話履歴を取得するわけではなく、履歴単位(historyId)での取得に対応する。返却する会話履歴は古いの物から順に返却する。

ユーザIDはHTTPヘッダー(x-nec-genai-client-id)が必須。履歴作成時のユーザ以外は取得できないように制限する。

存在しない履歴を指定した場合はエラー

Authorizations:
bearerAuth
path Parameters
historyId
required
string

履歴ID(uuidかhistory_でなければエラー)

maxnum
required
integer

最大取得件数(範囲:1-100)

header Parameters
Content-Type
required
string

application/json を固定で指定

x-nec-genai-client-id
required
string

APIの使用者を特定するためのID。呼び出し元側でユーザIDなど一意なIDを指定する必要がある(メールアドレス推奨)。API側では会話履歴などのリソースへのアクセス制御などに使用される

x-nec-genai-api-version
string

APIのバージョン。現時点では使用していない(将来使用する可能性あり)

Responses

Response samples

Content type
application/json
{
  • "error": {
    },
  • "contents": [
    ]
}

一連の会話履歴を更新

一連の会話履歴の更新を行う。現在対応しているのはタイトルのみ。

ユーザIDはHTTPヘッダー(x-nec-genai-client-id)が必須。ユーザIDに紐づいた履歴を更新する。

存在しない履歴を指定した場合もエラーにしない

Authorizations:
bearerAuth
path Parameters
historyId
required
string

履歴ID(uuidかhistory_でなければエラー)

header Parameters
Content-Type
required
string

application/json を固定で指定

x-nec-genai-client-id
required
string

APIの使用者を特定するためのID。呼び出し元側でユーザIDなど一意なIDを指定する必要がある(メールアドレス推奨)。API側では会話履歴などのリソースへのアクセス制御などに使用される

x-nec-genai-api-version
string

APIのバージョン。現時点では使用していない(将来使用する可能性あり)

Request Body schema: application/json
required
title
required
string (title)

会話のタイトル

Responses

Request samples

Content type
application/json
{
  • "title": "更新後のタイトル"
}

Response samples

Content type
application/json
{
  • "error": {
    },
  • "historyId": "history_12345678-90ab-cdef-ghij-zzz",
  • "count": 10
}

履歴削除

履歴削除を行う。履歴単位(historyId)での削除に対応する。ユーザIDに紐づいた履歴を削除する。

Authorizations:
bearerAuth
path Parameters
historyId
required
string

履歴ID(uuidかhistory_でなければエラー)

header Parameters
Content-Type
required
string

application/json を固定で指定

x-nec-genai-client-id
required
string

APIの使用者を特定するためのID。呼び出し元側でユーザIDなど一意なIDを指定する必要がある(メールアドレス推奨)。API側では会話履歴などのリソースへのアクセス制御などに使用される

x-nec-genai-api-version
string

APIのバージョン。現時点では使用していない(将来使用する可能性あり)

Responses

インデックス情報取得

インデックス情報をリストで返す。

Authorizations:
bearerAuth
header Parameters
Content-Type
required
string

application/json を固定で指定

Responses

Response samples

Content type
application/json
{
  • "indexes": [
    ]
}

基本情報を取得

管理UIバックエンドに、基本情報を取得する

Authorizations:
bearerAuth
header Parameters
Content-Type
required
string

application/json を固定で指定

Responses

Response samples

Content type
application/json
{
  • "tenant_id": "string",
  • "plan": "string",
  • "vector": {
    },
  • "api": {},
  • "llm": [
    ],
  • "embedding": [
    ]
}

個別テンプレート取得(利用者作成)

URIに指定したidに一致するテンプレートの詳細情報を返却する。返却するテンプレートは、ユーザの所属するtenantIdに属するもののみ返却する。

Authorizations:
bearerAuth
path Parameters
template_id
required
string (Template ID) <= 45 characters ^(template_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4...
header Parameters
Content-Type
required
string

application/json を固定で指定

Responses

Response samples

Content type
application/json
Example
{
  • "id": "string",
  • "name": "string",
  • "description": "string",
  • "systemPrompt": "string",
  • "userPrompt": "string",
  • "timestamp": 0,
  • "author": "string",
  • "groupId": "string",
  • "groupName": "string"
}

テンプレート一覧取得

テンプレートを一覧で取得する。なお、操作を行うユーザが所属するtenantIdに紐づくテンプレートのみ返却される。

Authorizations:
bearerAuth
header Parameters
Content-Type
required
string

application/json を固定で指定

Responses

Response samples

Content type
application/json
{
  • "user": [
    ],
  • "system": [
    ]
}

個別テンプレート取得(システム)

URIに指定したidに一致する標準テンプレート(システムテンプレート)の詳細情報を返却する。リクエストのユーザのテナントにかかわらずリクエストを受けた標準テンプレート情報を返却する。

Authorizations:
bearerAuth
path Parameters
template_id
required
string (Template Id)
header Parameters
Content-Type
required
string

application/json を固定で指定

Responses

Response samples

Content type
application/json
Example
{
  • "id": "string",
  • "name": "string",
  • "description": "string",
  • "systemPrompt": "string",
  • "userPrompt": "string",
  • "timestamp": 0,
  • "author": "string",
  • "groupId": "string",
  • "groupName": "string"
}

ユーザ情報取得

利用者のユーザ情報を返す。

Authorizations:
bearerAuth
header Parameters
Content-Type
required
string

application/json を固定で指定

Responses

Response samples

Content type
application/json
{
  • "user_id": "string",
  • "name": "string",
  • "email": "string",
  • "roles": [
    ]
}