Skip to content

非公式本サイトは非公式の日本語ドキュメントであり、Cloudflare 公式サイトではありません。最新情報はdevelopers.cloudflare.comをご確認ください。

Parallel

最終更新 Markdown で表示Agent セットアップ

Parallel は AI 向けに作られた Web API です。幻覚(ハルシネーション)を抑え、根拠のある本番向けの出力を返します。

エンドポイント

https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallel

URL 構成

Parallel にリクエストを送るときは、parallel の後ろにパスを付けると、任意の Parallel エンドポイントを AI Gateway 経由でルーティングできます。たとえば Tasks API の /v1/tasks/runs にアクセスする場合は、次を使います。

https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallel/v1/tasks/runs

前提条件

Parallel にリクエストを送るときは、次を用意します。

  • AI Gateway の Account ID
  • AI Gateway のゲートウェイ名
  • 有効な Parallel API キー

Tasks API

Tasks API では、包括的な調査・分析タスクを作成できます。

cURL の例

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

Search API では、設定可能なパラメーターで高度な検索ができます。

cURL の例

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

Chat API は、AI Gateway の Unified Chat Completions API 経由で使えます。詳細は次を参照してください。

OpenAI 互換エンドポイント

REST API 経由で、OpenAI API スキーマを使って Parallel モデルにもアクセスできます。リクエストの送信先は次のとおりです。

https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1/chat/completions

次を指定します。


{
"model": "parallel/{model}"
}

JavaScript SDK の例

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

FindAll API では、複雑なクエリから構造化データを抽出できます。

cURL の例

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."
  }'

役に立ちましたか?