Skip to content

Commit b332385

Browse files
update readme
1 parent cb97acd commit b332385

1 file changed

Lines changed: 63 additions & 15 deletions

File tree

README.md

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ It is generated with [Stainless](https://www.stainless.com/).
1111

1212
## Documentation
1313

14-
The REST API documentation can be found on our [docs](https://docs.parallel.ai).
14+
The REST API documentation can be found in our [docs](https://docs.parallel.ai).
1515
The full API of this Python library can be found in [api.md](api.md).
1616

1717
## Installation
@@ -38,14 +38,19 @@ run_result = client.task_run.execute(
3838
processor="core",
3939
output="GDP"
4040
)
41-
print(run_result.output)
41+
print(run_result.output.parsed)
4242
```
4343

4444
While you can provide an `api_key` keyword argument,
4545
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
4646
to add `PARALLEL_API_KEY="My API Key"` to your `.env` file
4747
so that your API Key is not stored in source control.
4848

49+
The API also supports typed inputs and outputs via Pydantic objects. See the relevant
50+
section on [convenience methods](#convenience-methods).
51+
52+
For information on what tasks are and how to specify them, see [our docs](https://docs.parallel.ai/task-api/core-concepts/specify-a-task).
53+
4954
## Async usage
5055

5156
Simply import `AsyncParallel` instead of `Parallel` and use `await` with each API call:
@@ -66,7 +71,7 @@ async def main() -> None:
6671
processor="core",
6772
output="GDP"
6873
)
69-
print(run_result.output)
74+
print(run_result.output.parsed)
7075

7176

7277
if __name__ == "__main__":
@@ -75,16 +80,17 @@ if __name__ == "__main__":
7580

7681
To get the best performance out of Parallel's API, we recommend
7782
using the asynchronous client, especially for executing multiple Task Runs concurrently.
78-
Functionality between the synchronous and asynchronous clients is identical.
83+
Functionality between the synchronous and asynchronous clients is identical, including
84+
the convenience methods.
7985

8086
## Convenience methods
8187

8288
### Execute
8389

84-
The `execute` method provides a single call which combines creating a task run,
85-
polling until it is completed, and parsing structured outputs (if specified).
90+
The `execute` method provides a single call that combines creating a task run,
91+
polling until completion, and parsing structured outputs (if specified).
8692

87-
If an output type which inherits from `BaseModel` is
93+
If an output type that inherits from `BaseModel` is
8894
specified in the call to `.execute()`, the response content will be parsed into an
8995
instance of the provided output type. The parsed output can be accessed via the
9096
`parsed` property on the output field of the response.
@@ -115,15 +121,15 @@ async def main() -> None:
115121
processor="core",
116122
output="GDP"
117123
)
118-
print(run_result.output)
124+
print(run_result.output.parsed)
119125

120126

121127
if __name__ == "__main__":
122128
asyncio.run(main())
123129
```
124130

125-
The async client allows creating several task runs without blocking.
126-
To create multiple task runs in one go, call execute and then gather the results at the end.
131+
The async client lets you create multiple task runs without blocking.
132+
To submit several at once, call `execute()` and gather the results at the end.
127133

128134
```python
129135
import asyncio
@@ -181,9 +187,51 @@ if __name__ == "__main__":
181187
asyncio.run(main())
182188
```
183189

184-
## Low level API Access
190+
#### `execute()` vs `create()`
191+
192+
The `execute` and `create` methods differ slightly in their signatures and
193+
behavior — `create` requires a Task Spec object that contains the output schema,
194+
while `execute` accepts an output schema as a top‑level parameter. `execute` is
195+
also a one‑shot method that combines creation, polling, and parsing for you.
196+
197+
Use `create` when you want a run ID immediately and prefer to control polling
198+
yourself. `execute` is best for one‑shot task execution and for typed inputs and
199+
outputs — note that no outputs are available until the call finishes. Finally, for
200+
the output of `execute`, parsed content is available via `run_result.output.parsed`.
201+
202+
Both `execute` and `create` validate inputs when appropriate input types are
203+
provided. For `execute`, validation happens when a pydantic input is provided. For
204+
`create`, validation occurs when the input schema is specified inside the task spec
205+
parameter. Additionally, in both calls, the un-parsed result content is accessible via
206+
the `run_result.output.content`.
207+
208+
## Frequently Asked Questions
209+
210+
**Does the Task API accept prompts or objectives?**
211+
212+
No, there are no `objective` or `prompt` parameters that can be specified for calls to
213+
the Task API. Instead, provide any directives or instructions via the schemas. For
214+
more information, check [our docs](https://docs.parallel.ai/task-api/core-concepts/specify-a-task).
215+
216+
**Can I access beta parameters or endpoints via the SDK?**
217+
218+
The SDK currently does not support beta parameters in the Task API. You can consider
219+
using [custom requests](#making-customundocumented-requests) in conjunction with
220+
[low level APIs](#lowlevel-api-access).
221+
222+
**Can I specify a timeout for API calls?**
223+
224+
Yes, all methods support a timeout. For more information, see [Timeouts](#timeouts).
225+
226+
**Can I specify retries via the SDK?**
227+
228+
Yes, errors can be retried via the SDK — the default retry count is 2. The maximum number
229+
of retries can be configured at the client level. For information on which errors
230+
are automatically retried and how to configure retry settings, see [Retries](#retries).
231+
232+
## Low‑level API access
185233

186-
The library also provides access to the low level API for accessing the Parallel API.
234+
The library also provides lowlevel access to the Parallel API.
187235

188236
```python
189237
from parallel import Parallel
@@ -231,13 +279,13 @@ task_run = client.task_run.create(
231279
)
232280

233281
run_result = client.task_run.result(task_run.run_id)
234-
print(run_result.output)
282+
print(run_result.output.content)
235283
```
236284

237285
For more information, please check out the relevant section in our docs:
238286

239-
- [Task Spec](https://docs.parallel.ai/core-concepts/task-spec)
240-
- [Task Runs](https://docs.parallel.ai/core-concepts/task-runs)
287+
- [Task Spec](https://docs.parallel.ai/task-api/core-concepts/specify-a-task)
288+
- [Task Runs](https://docs.parallel.ai/task-api/core-concepts/execute-task-run)
241289

242290
## Handling errors
243291

0 commit comments

Comments
 (0)