Skip to content

Commit 01b1eca

Browse files
authored
docs: improve API SDK docs (#190)
1 parent 86e965f commit 01b1eca

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

docs/api_sdk.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@ This guide shows you how to authenticate and configure the AsyncDeepsetClient fo
1313
**Using environment variables (recommended):**
1414

1515
```python
16-
import asyncio
1716
from deepset_mcp.api import AsyncDeepsetClient
1817

19-
async def main():
20-
# Reads DEEPSET_API_KEY from environment
21-
async with AsyncDeepsetClient() as client:
22-
workspaces = await client.workspaces().list()
23-
print(f"Available workspaces: {len(workspaces.data)}")
24-
25-
asyncio.run(main())
18+
# Reads DEEPSET_API_KEY from environment
19+
async with AsyncDeepsetClient() as client:
20+
workspaces = await client.workspaces().list()
21+
print(f"Available workspaces: {len(workspaces)}")
2622
```
2723

2824
**Providing credentials directly:**
@@ -185,7 +181,7 @@ async with AsyncDeepsetClient() as client:
185181

186182
# List all workspaces
187183
workspaces = await workspaces_client.list()
188-
for workspace in workspaces.data:
184+
for workspace in workspaces:
189185
print(f"Workspace: {workspace.name} (ID: {workspace.workspace_id})")
190186

191187
# Use workspace-specific resources
@@ -382,6 +378,24 @@ async with AsyncDeepsetClient() as client:
382378
print(f"[{log_entry.timestamp}] {log_entry.level}: {log_entry.message}")
383379
```
384380

381+
### How to Use in Synchronous Environments
382+
383+
This guide shows how to make API requests through the client in synchronous contexts.
384+
385+
```python
386+
import asyncio
387+
from deepset_mcp.api import AsyncDeepsetClient
388+
389+
client = AsyncDeepsetClient()
390+
pipelines = client.pipelines("my-workspace")
391+
my_pipeline = asyncio.run(pipelines.get("my-pipeline"))
392+
393+
valid = asyncio.run(pipelines.validate(my_pipeline.yaml_config))
394+
395+
if valid.valid:
396+
print("The pipeline is valid!")
397+
```
398+
385399

386400
## Concepts
387401

0 commit comments

Comments
 (0)