← Cloudflare AI Gateway / ai-gateway / usage / providers
Parallel
Parallel ↗ je webové API navržené přímo pro AI, které poskytuje produkčně připravené výstupy s minimem halucinací a výsledky podložené důkazy.
Endpoint
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallelStruktura URL
Při odesílání požadavků do Parallel můžete přes AI Gateway směrovat na libovolný koncový bod Parallel připojením cesty za parallel. Pro přístup k Tasks API na adrese /v1/tasks/runs, použijte:
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallel/v1/tasks/runsPředpoklady
Při odesílání požadavků do Parallel se ujistěte, že máte následující:
- Vaše AI Gateway Account ID.
- Název vaší gateway v AI Gateway.
- Aktivní API klíč Parallel.
Příklady
Tasks API
Tasks API ↗ umožňuje vytvářet komplexní výzkumné a analytické úlohy.
Příklad 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 ↗ umožňuje pokročilé vyhledávání s konfigurovatelnými parametry.
Příklad 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 ↗ je podporována prostřednictvím Unified Chat Completions API v AI Gateway. Další podrobnosti najdete níže:
Koncový bod kompatibilní s OpenAI
K modelům Parallel můžete přistupovat také pomocí schématu OpenAI API prostřednictvím REST API. Odesílejte své požadavky na:
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1/chat/completionsZadejte:
{
"model": "parallel/{model}"
}Příklad SDK pro JavaScript
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 ↗ umožňuje strukturovanou extrakci dat ze složitých dotazů.
Příklad 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."
}'