Skip to main content
cpsl.Client is the lightweight Python client for talking to deployed Capsule apps from outside the app runtime. You will usually reach for it when the app already exists and you want to talk to it from somewhere else, such as a smoke test, admin script, or another Python service. It is useful for:
  • deploy smoke tests
  • scripts and admin tools
  • cron jobs
  • other Python services that want to call a Capsule app

Worked example

The most common use is a deploy smoke test for a real app:
That pattern is useful because it exercises both the app’s answer quality and its session continuity after a deploy.

Setup

The client authenticates from capsule login by default:
You can also pass a token manually:
If you have already run capsule login, the zero-argument form is usually all you need.

App lookup methods

Chat methods

chat(app, text, session_id=None)

Send a message and wait for the full response.
If you are writing a quick post-deploy smoke test, this is usually the most convenient entry point. Returns ChatResponse with:
  • text
  • session_id
  • request_id
  • raw

stream(app, text, session_id=None)

Stream a response via SSE:
This is handy when you want your script to show progress instead of waiting for the entire response. Each StreamChunk exposes:
  • event
  • data
  • text convenience property
  • done convenience property

Session continuity

Pass session_id if you want multiple client calls to continue the same conversation:
Without session_id, each call starts a fresh conversation.

Typical use

Example smoke test:

See also