Skip to content

Commit f7998f0

Browse files
thebongyRishit Bansal
andauthored
[AI Gateway] Add documentation for Parallel AI Provider (#25517)
Co-authored-by: Rishit Bansal <[email protected]>
1 parent 9357d6a commit f7998f0

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
title: Parallel
3+
pcx_content_type: get-started
4+
---
5+
6+
import { Render } from "~/components";
7+
8+
[Parallel](https://parallel.ai/) is a web API purpose-built for AIs, providing production-ready outputs with minimal hallucination and evidence-based results.
9+
10+
## Endpoint
11+
12+
```txt
13+
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallel
14+
```
15+
16+
## URL structure
17+
18+
When making requests to Parallel, you can route to any Parallel endpoint through AI Gateway by appending the path after `parallel`. For example, to access the Tasks API at `/v1/tasks/runs`, use:
19+
20+
```txt
21+
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallel/v1/tasks/runs
22+
```
23+
24+
## Prerequisites
25+
26+
When making requests to Parallel, ensure you have the following:
27+
28+
- Your AI Gateway Account ID.
29+
- Your AI Gateway gateway name.
30+
- An active Parallel API key.
31+
32+
## Examples
33+
34+
### Tasks API
35+
36+
The [Tasks API](https://docs.parallel.ai/task-api/task-quickstart) allows you to create comprehensive research and analysis tasks.
37+
38+
#### cURL example
39+
40+
```bash
41+
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallel/v1/tasks/runs \
42+
--header 'x-api-key: {parallel_api_key}' \
43+
--header 'Content-Type: application/json' \
44+
--data '{
45+
"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.",
46+
"processor": "ultra"
47+
}'
48+
```
49+
50+
### Search API
51+
52+
The [Search API](https://docs.parallel.ai/search-api/search-quickstart) enables advanced search with configurable parameters.
53+
54+
#### cURL example
55+
56+
```bash
57+
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallel/v1beta/search \
58+
--header 'x-api-key: {parallel_api_key}' \
59+
--header 'Content-Type: application/json' \
60+
--data '{
61+
"objective": "When was the United Nations established? Prefer UN'\''s websites.",
62+
"search_queries": [
63+
"Founding year UN",
64+
"Year of founding United Nations"
65+
],
66+
"processor": "base",
67+
"max_results": 10,
68+
"max_chars_per_result": 6000
69+
}'
70+
```
71+
72+
## Chat API
73+
74+
The [Chat API](https://docs.parallel.ai/chat-api/chat-quickstart) is supported through AI Gateway's Unified Chat Completions API. See below for more details:
75+
76+
<Render
77+
file="chat-completions-providers"
78+
product="ai-gateway"
79+
params={{
80+
name: "Parallel",
81+
jsonexample: `
82+
{
83+
"model": "parallel/{model}"
84+
}`
85+
86+
}}
87+
88+
/>
89+
90+
#### JavaScript SDK example
91+
92+
```js
93+
import OpenAI from "openai";
94+
95+
const apiKey = "{parallel_api_key}";
96+
const accountId = "{account_id}";
97+
const gatewayId = "{gateway_id}";
98+
const baseURL = `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/compat`;
99+
100+
const client = new OpenAI({
101+
apiKey,
102+
baseURL,
103+
});
104+
105+
try {
106+
const model = "parallel/speed";
107+
const messages = [{ role: "user", content: "Hello!" }];
108+
const chatCompletion = await client.chat.completions.create({
109+
model,
110+
messages,
111+
});
112+
const response = chatCompletion.choices[0].message;
113+
console.log(response);
114+
} catch (e) {
115+
console.error(e);
116+
}
117+
```
118+
119+
### FindAll API
120+
121+
The [FindAll API](https://docs.parallel.ai/findall-api/findall-quickstart) enables structured data extraction from complex queries.
122+
123+
#### cURL example
124+
125+
```bash
126+
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/parallel/v1beta/findall/ingest \
127+
--header 'x-api-key: {parallel_api_key}' \
128+
--header 'Content-Type: application/json' \
129+
--data '{
130+
"query": "Find all AI companies that recently raised money and get their website, CEO name, and CTO name."
131+
}'
132+
```

0 commit comments

Comments
 (0)