Generative AI API (1.0)

Download OpenAPI specification:Download

一般対話API

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

Authorizations:
bearerAuth
header Parameters
Content-Type
required
string

application/json を固定で指定

x-nec-cotomi-client-id
required
string

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

x-nec-cotomi-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-v1.0",
  • "stream": false,
  • "streamNum": 1,
  • "maxTokens": 1024,
  • "temperature": 1
}

Response samples

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

検索対話

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

Authorizations:
bearerAuth
header Parameters
Content-Type
required
string

application/json を固定で指定

x-nec-cotomi-client-id
required
string

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

x-nec-cotomi-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-v1.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-cotomi-client-id
required
string

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

x-nec-cotomi-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-v1.0",
  • "stream": true,
  • "streamNum": 3,
  • "maxTokens": 1024,
  • "temperature": 1
}

Response samples

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

ユーザの履歴一覧を取得

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

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

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

Authorizations:
bearerAuth
path Parameters
maxnum
required
integer

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

header Parameters
Content-Type
required
string

application/json を固定で指定

x-nec-cotomi-client-id
required
string

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

x-nec-cotomi-api-version
string

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

Responses

Response samples

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

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

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

ユーザIDはHTTPヘッダー(x-nec-cotomi-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-cotomi-client-id
required
string

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

x-nec-cotomi-api-version
string

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

Responses

Response samples

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

一連の会話履歴を更新

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

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

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

Authorizations:
bearerAuth
path Parameters
historyId
required
string

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

header Parameters
Content-Type
required
string

application/json を固定で指定

x-nec-cotomi-client-id
required
string

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

x-nec-cotomi-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-cotomi-client-id
required
string

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

x-nec-cotomi-api-version
string

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

Responses