Parallel ↗ は AI 向けに作られた Web API です。幻覚(ハルシネーション)を抑え、根拠のある本番向けの出力を返します。
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallelParallel にリクエストを送るときは、parallel の後ろにパスを付けると、任意の Parallel エンドポイントを AI Gateway 経由でルーティングできます。たとえば Tasks API の /v1/tasks/runs にアクセスする場合は、次を使います。
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallel/v1/tasks/runsParallel にリクエストを送るときは、次を用意します。
- AI Gateway の Account ID
- AI Gateway のゲートウェイ名
- 有効な Parallel API キー
Tasks API ↗ では、包括的な調査・分析タスクを作成できます。
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallel/v1/tasks/runs \
--header 'x-api-key: {parallel_api_key}' \
--header 'Content-Type: application/json' \
--data '{
"input": "Create a comprehensive market research report on the HVAC industry in the USA including an analysis of recent M&A activity and other relevant details.",
"processor": "ultra"
}'Search API ↗ では、設定可能なパラメーターで高度な検索ができます。
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallel/v1beta/search \
--header 'x-api-key: {parallel_api_key}' \
--header 'Content-Type: application/json' \
--data '{
"objective": "When was the United Nations established? Prefer UN'\''s websites.",
"search_queries": [
"Founding year UN",
"Year of founding United Nations"
],
"processor": "base",
"max_results": 10,
"max_chars_per_result": 6000
}'Chat API ↗ は、AI Gateway の Unified Chat Completions API 経由で使えます。詳細は次を参照してください。
REST API 経由で、OpenAI API スキーマを使って Parallel モデルにもアクセスできます。リクエストの送信先は次のとおりです。
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1/chat/completions次を指定します。
{
"model": "parallel/{model}"
}import OpenAI from "openai";
const apiKey = "{parallel_api_key}";
const accountId = "{account_id}";
const gatewayId = "{gateway_id}";
const baseURL = `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/compat`;
const client = new OpenAI({
apiKey,
baseURL,
});
try {
const model = "parallel/speed";
const messages = [{ role: "user", content: "Hello!" }];
const chatCompletion = await client.chat.completions.create({
model,
messages,
});
const response = chatCompletion.choices[0].message;
console.log(response);
} catch (e) {
console.error(e);
}FindAll API ↗ では、複雑なクエリから構造化データを抽出できます。
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallel/v1beta/findall/ingest \
--header 'x-api-key: {parallel_api_key}' \
--header 'Content-Type: application/json' \
--data '{
"query": "Find all AI companies that recently raised money and get their website, CEO name, and CTO name."
}'