Python SDK

Look up the common APIs for calling an Agent from a Python application. For model setup, runnable examples, and expected results, see Call an Agent with the Python SDK.

Prepare the runtime

Call Behavior
prepare_runtime() Read the configuration from DataAgent Home and return a runtime for create_agent().
prepare_runtime(LaunchOptions(config=path)) Use the specified product YAML.

Create and call an Agent

create_agent(runtime) returns an Agent. agent.invoke(inputs, config=...) runs one turn synchronously and returns the final graph state. For a normal conversation, send the new message in inputs["messages"] and read the reply from the returned messages. Use with to manage the Agent lifecycle.

Select a session

Set config["configurable"]["thread_id"] to select the session. Use a different ID to start a new session. To continue a conversation, reuse its ID and configure a persistent SQLite checkpointer. See the Python SDK usage guide.

Async and streaming calls

ainvoke() waits for the final result. astream() yields updates while the Agent runs, so a client can display progress. See the async and streaming example.

If configuration fails, check your model settings and YAML. See model configuration and first call.

Extension and host development