Given:
- Installed Copilot CLI
- Python SDK
- OS: Windows
- VS Code 1.109.0
import asyncio
from copilot import CopilotClient
async def main():
client = CopilotClient()
await client.start()
session = await client.create_session({"model": "gpt-4.1"})
response = await session.send_and_wait({"prompt": "What is 2 + 2?"})
print(response.data.content)
await client.stop()
asyncio.run(main())
DON'T WORK VS Code terminal:
File "C:\Users<user>\AppData\Roaming\uv\python\cpython-3.12.11-windows-x86_64-none\Lib\asyncio\tasks.py", line 520, in wait_for
return await fut
^^^^^^^^^
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
Reinstall GitHub Copilot CLI? (y/N):
Reinstall GitHub Copilot CLI? (y/N):
Reinstall GitHub Copilot CLI? (y/N):
Reinstall GitHub Copilot CLI? (y/N):
WORKS Command prompt:
Works!!