Skip to content
4 changes: 2 additions & 2 deletions docs/auth/byok.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ Azure AI Foundry (formerly Azure OpenAI) is a common BYOK deployment target for
```python
import asyncio
import os
from copilot import CopilotClient
import copilot

FOUNDRY_MODEL_URL = "https://your-resource.openai.azure.com/openai/v1/"
# Set FOUNDRY_API_KEY environment variable

async def main():
client = CopilotClient()
client = copilot.cli_client()
await client.start()

session = await client.create_session({
Expand Down
21 changes: 9 additions & 12 deletions docs/auth/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ const client = new CopilotClient();
<summary><strong>Python</strong></summary>

```python
from copilot import CopilotClient
import copilot

# Default: uses logged-in user credentials
client = CopilotClient()
client = copilot.cli_client()
await client.start()
```

Expand Down Expand Up @@ -106,12 +106,11 @@ const client = new CopilotClient({
<summary><strong>Python</strong></summary>

```python
from copilot import CopilotClient
import copilot

client = CopilotClient({
"github_token": user_access_token, # Token from OAuth flow
"use_logged_in_user": False, # Don't use stored CLI credentials
})
client = copilot.cli_client(
github_token=user_access_token, # Token from OAuth flow
)
await client.start()
```

Expand Down Expand Up @@ -194,10 +193,10 @@ const client = new CopilotClient();
<summary><strong>Python</strong></summary>

```python
from copilot import CopilotClient
import copilot

# Token is read from environment variable automatically
client = CopilotClient()
client = copilot.cli_client()
await client.start()
```

Expand Down Expand Up @@ -256,9 +255,7 @@ const client = new CopilotClient({

<!-- docs-validate: skip -->
```python
client = CopilotClient({
"use_logged_in_user": False, # Only use explicit tokens
})
client = copilot.cli_client(use_logged_in_user=False) # Only use explicit tokens
```

</details>
Expand Down
8 changes: 4 additions & 4 deletions docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const client = new CopilotClient({
<summary><strong>Python</strong></summary>

```python
from copilot import CopilotClient
import copilot

client = CopilotClient({"log_level": "debug"})
client = copilot.cli_client(log_level="debug")
```

</details>
Expand Down Expand Up @@ -164,7 +164,7 @@ var client = new CopilotClient(new CopilotClientOptions
<summary><strong>Python</strong></summary>

```python
client = CopilotClient({"cli_path": "/usr/local/bin/copilot"})
client = copilot.cli_client("/usr/local/bin/copilot")
```
</details>

Expand Down Expand Up @@ -217,7 +217,7 @@ var client = new CopilotClient(new CopilotClientOptions

```python
import os
client = CopilotClient({"github_token": os.environ.get("GITHUB_TOKEN")})
client = copilot.cli_client(github_token=os.environ.get("GITHUB_TOKEN"))
```
</details>

Expand Down
23 changes: 11 additions & 12 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ Create `main.py`:

```python
import asyncio
from copilot import CopilotClient
import copilot

async def main():
client = CopilotClient()
client = copilot.cli_client()
await client.start()

session = await client.create_session({"model": "gpt-4.1"})
Expand Down Expand Up @@ -274,11 +274,11 @@ Update `main.py`:
```python
import asyncio
import sys
from copilot import CopilotClient
import copilot
from copilot.generated.session_events import SessionEventType

async def main():
client = CopilotClient()
client = copilot.cli_client()
await client.start()

session = await client.create_session({
Expand Down Expand Up @@ -565,7 +565,7 @@ Update `main.py`:
import asyncio
import random
import sys
from copilot import CopilotClient
import copilot
from copilot.tools import define_tool
from copilot.generated.session_events import SessionEventType
from pydantic import BaseModel, Field
Expand All @@ -585,7 +585,7 @@ async def get_weather(params: GetWeatherParams) -> dict:
return {"city": city, "temperature": f"{temp}°F", "condition": condition}

async def main():
client = CopilotClient()
client = copilot.cli_client()
await client.start()

session = await client.create_session({
Expand Down Expand Up @@ -837,7 +837,7 @@ Create `weather_assistant.py`:
import asyncio
import random
import sys
from copilot import CopilotClient
import copilot
from copilot.tools import define_tool
from copilot.generated.session_events import SessionEventType
from pydantic import BaseModel, Field
Expand All @@ -854,7 +854,7 @@ async def get_weather(params: GetWeatherParams) -> dict:
return {"city": city, "temperature": f"{temp}°F", "condition": condition}

async def main():
client = CopilotClient()
client = copilot.cli_client()
await client.start()

session = await client.create_session({
Expand Down Expand Up @@ -1210,11 +1210,10 @@ const session = await client.createSession({ onPermissionRequest: approveAll });
<summary><strong>Python</strong></summary>

```python
from copilot import CopilotClient, PermissionHandler
import copilot
from copilot import PermissionHandler

client = CopilotClient({
"cli_url": "localhost:4321"
})
client = copilot.network_client("localhost:4321")
await client.start()

# Use the client normally
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/session-persistence.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ await session.sendAndWait({ prompt: "Analyze my codebase" });
### Python

```python
from copilot import CopilotClient
import copilot

client = CopilotClient()
client = copilot.cli_client()
await client.start()

# Create a session with a meaningful ID
Expand Down
10 changes: 6 additions & 4 deletions docs/guides/setup/azure-managed-identity.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ import asyncio
import os

from azure.identity import DefaultAzureCredential
from copilot import CopilotClient, ProviderConfig, SessionConfig
import copilot
from copilot import ProviderConfig, SessionConfig

COGNITIVE_SERVICES_SCOPE = "https://cognitiveservices.azure.com/.default"

Expand All @@ -54,7 +55,7 @@ async def main():

foundry_url = os.environ["AZURE_AI_FOUNDRY_RESOURCE_URL"]

client = CopilotClient()
client = copilot.cli_client()
await client.start()

session = await client.create_session(
Expand Down Expand Up @@ -84,7 +85,8 @@ Bearer tokens expire (typically after ~1 hour). For servers or long-running agen

```python
from azure.identity import DefaultAzureCredential
from copilot import CopilotClient, ProviderConfig, SessionConfig
import copilot
from copilot import ProviderConfig, SessionConfig

COGNITIVE_SERVICES_SCOPE = "https://cognitiveservices.azure.com/.default"

Expand All @@ -96,7 +98,7 @@ class ManagedIdentityCopilotAgent:
self.foundry_url = foundry_url.rstrip("/")
self.model = model
self.credential = DefaultAzureCredential()
self.client = CopilotClient()
self.client = copilot.cli_client()

def _get_session_config(self) -> SessionConfig:
"""Build a SessionConfig with a fresh bearer token."""
Expand Down
6 changes: 2 additions & 4 deletions docs/guides/setup/backend-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ res.json({ content: response?.data.content });
<summary><strong>Python</strong></summary>

```python
from copilot import CopilotClient
import copilot

client = CopilotClient({
"cli_url": "localhost:4321",
})
client = copilot.network_client("localhost:4321")
await client.start()

session = await client.create_session({
Expand Down
6 changes: 2 additions & 4 deletions docs/guides/setup/bundled-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,10 @@ await client.stop();
<summary><strong>Python</strong></summary>

```python
from copilot import CopilotClient
import copilot
from pathlib import Path

client = CopilotClient({
"cli_path": str(Path(__file__).parent / "vendor" / "copilot"),
})
client = copilot.cli_client(str(Path(__file__).parent / "vendor" / "copilot"))
await client.start()

session = await client.create_session({"model": "gpt-4.1"})
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/setup/byok.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ await client.stop();

```python
import os
from copilot import CopilotClient
import copilot

client = CopilotClient()
client = copilot.cli_client()
await client.start()

session = await client.create_session({
Expand Down
8 changes: 4 additions & 4 deletions docs/guides/setup/github-oauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ const response = await session.sendAndWait({ prompt: "Hello!" });
<summary><strong>Python</strong></summary>

```python
import copilot
from copilot import CopilotClient

def create_client_for_user(user_token: str) -> CopilotClient:
return CopilotClient({
"github_token": user_token,
"use_logged_in_user": False,
})
return copilot.cli_client(
github_token=user_token,
)

# Usage
client = create_client_for_user("gho_user_access_token")
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/setup/local-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ await client.stop();
<summary><strong>Python</strong></summary>

```python
from copilot import CopilotClient
import copilot

client = CopilotClient()
client = copilot.cli_client()
await client.start()

session = await client.create_session({"model": "gpt-4.1"})
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ await session.sendAndWait({ prompt: "Review this code for security issues" });
<summary><strong>Python</strong></summary>

```python
from copilot import CopilotClient
import copilot

async def main():
client = CopilotClient()
client = copilot.cli_client()
await client.start()

session = await client.create_session({
Expand Down
4 changes: 2 additions & 2 deletions docs/hooks/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ const session = await client.createSession({
<summary><strong>Python</strong></summary>

```python
from copilot import CopilotClient
import copilot

async def main():
client = CopilotClient()
client = copilot.cli_client()
await client.start()

async def on_pre_tool_use(input_data, invocation):
Expand Down
4 changes: 2 additions & 2 deletions docs/mcp/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ const session = await client.createSession({

```python
import asyncio
from copilot import CopilotClient
import copilot

async def main():
client = CopilotClient()
client = copilot.cli_client()
await client.start()

session = await client.create_session({
Expand Down
Loading