# ClaudeSDKClient

> A Python class that keeps one chat open for many prompts.

**Field:** Artificial Intelligence  
**Category:** Claude Agent SDK  
**Also known as:** Python SDK client, ClaudeSDKClient class

## Think of it like

It is like a phone call you keep open. You do not hang up after each question.

## Definition

ClaudeSDKClient is a Python class in the Agent SDK that keeps one session open. Each call to its query method goes on with the same chat, so the agent recalls what came before. You read the reply with receive_response. It can also stop a turn with interrupt. TypeScript has no such class, and uses continue or resume.

## Example

Mia builds a chat app in Python. She keeps one ClaudeSDKClient per user, so each follow-up knows the earlier messages.

## Example code

```python
async with ClaudeSDKClient() as client:
    await client.query("Read auth.py")
    async for m in client.receive_response():
        print(m)
```

Open a client, send a prompt, and read the reply.

## Why it matters

A chat needs memory across prompts, and the client keeps it with no IDs to track.

## Common mistake

Calling query() again for a follow-up and losing the context. Use the client, or pass resume.

## Three principles

- **One open session.** Many prompts.
- **receive_response().** Reads the reply.
- **Python only.** TypeScript uses continue.

## Related terms

- [query() Function](https://learn.benibix.com/term/ai/query-function)
- [Streaming Input Mode](https://learn.benibix.com/term/ai/streaming-input-mode)
- [Claude Code Session](https://learn.benibix.com/term/ai/claude-code-session)
- [interrupt() Method](https://learn.benibix.com/term/ai/interrupt-method)

## Told apart from

- [query() vs ClaudeSDKClient](https://learn.benibix.com/compare/query-function-vs-claude-sdk-client): People think query() and ClaudeSDKClient are two names for the same thing. query() runs a task and ends, and each new call starts fresh unless you pass resume or continue. ClaudeSDKClient is a Python class that keeps one session open, so each prompt you send remembers the ones before. Use query() for one job, and the client for a chat.

---

Source: https://learn.benibix.com/term/ai/claude-sdk-client
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-20
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
