KubiyaClient
The main entry point for interacting with Kubiya platform APIs.Class: KubiyaClient
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | None | Kubiya API key. If not provided, reads from KUBIYA_API_KEY env var |
base_url | str | "https://api.kubiya.ai" | API endpoint URL |
timeout | int | 30 | Request timeout in seconds |
retry_attempts | int | 3 | Number of retries for failed requests |
debug | bool | False | Enable debug logging |
Services
The client provides access to these services:client.agents- Agents Serviceclient.workflows- Workflows Serviceclient.integrations- Integrations Serviceclient.secrets- Secrets Serviceclient.knowledge- Knowledge Service
Methods
execute_workflow(workflow_dict, stream=False, runner=None)
Execute a workflow.
workflow_dict(dict): Workflow definition as dictionarystream(bool): Enable streaming responserunner(str, optional): Runner name
stream=True) or execution result
Agents Service
client.agents.create(...)
Create a new agent.
uuid, name, and other properties
client.agents.list(limit=10, offset=0, filter_term=None)
List agents.
Returns: List of agent objects
client.agents.get(agent_uuid)
Get agent details.
Returns: Agent object
client.agents.edit(agent_uuid, **kwargs)
Update agent configuration.
client.agents.delete(agent_uuid)
Delete an agent.
Access Control
client.agents.access.show(agent_uuid)client.agents.access.add_user(agent_uuid, users: List[str])client.agents.access.add_group(agent_uuid, groups: List[str])client.agents.access.remove_user(agent_uuid, users: List[str])client.agents.access.clear(agent_uuid)
Environment Variables
client.agents.env.list(agent_uuid)client.agents.env.set(agent_uuid, env_vars: Dict[str, str])client.agents.env.unset(agent_uuid, var_names: List[str])
AI Instructions
client.agents.prompt.get(agent_uuid)client.agents.prompt.set(agent_uuid, instructions: str)
Workflows Service
client.workflows.execute(...)
Execute a workflow.
workflow_definition: Workflow as dict or JSON stringparameters: Parameters to pass to workflowrunner: Runner name (optional)stream: Enable streaming
client.workflows.list(filter=None, limit=10, offset=0)
List workflow executions.
Returns: List of execution objects
Integrations Service
client.integrations.activate(integration_name)
Activate an integration.
success and optional install_url
client.integrations.list()
List active integrations.
Secrets Service
client.secrets.create(name, value, description=None)
Create a secret.
client.secrets.list()
List secrets (metadata only, not values).
Returns: List of secret metadata objects
client.secrets.get(name)
Get secret metadata.
client.secrets.value(name)
Get secret value.
Returns: The secret value as string
client.secrets.update(name, value=None, description=None)
Update a secret.
client.secrets.delete(name)
Delete a secret.
Knowledge Service
client.knowledge.query(prompt, stream=False)
Query the knowledge base.
prompt(str): The query promptstream(bool): Enable streaming
Workflow DSL
workflow(name)
Create a workflow.
Workflow Methods
| Method | Description |
|---|---|
.description(text) | Set workflow description |
.params(**kwargs) | Define workflow parameters |
.step(name, command) | Add a simple step |
.step(name, callback=fn) | Add a step with advanced configuration |
.runner(name) | Set the workflow runner |
.to_dict() | Convert to dictionary |
.to_json(indent=None) | Convert to JSON string |
.to_yaml() | Convert to YAML string |
Step Configuration
Step Callback Methods
| Method | Description |
|---|---|
.shell(command) | Execute shell command |
.python(code) | Execute Python code |
.docker(image, content) | Run in Docker container |
.kubiya(url, method, body=None) | Call Kubiya API |
.tool_def(...) | Define custom tool |
.depends(step_name) | Add dependency on another step |
.output(var_name) | Capture step output |
.condition(expression) | Add conditional execution |
.description(text) | Set step description |
.shell_type(type) | Set shell type (bash, sh, etc.) |
.script(content) | Set script content |
.args(**kwargs) | Set script arguments |
Examples
Async Client
StreamingKubiyaClient
Async version of the client for non-blocking operations.
Exceptions
kubiya.kubiya_services.exceptions
AgentError
Raised when agent operations fail.WorkflowExecutionError
Raised when workflow execution fails.IntegrationError
Raised when integration operations fail.IntegrationNotFoundError
Raised when integration is not found or already exists.SecretError
Raised when secret operations fail.SecretValidationError
Raised when secret validation fails.KnowledgeError
Raised when knowledge service operations fail.Type Hints
The SDK provides type hints for better IDE support:Environment Variables
| Variable | Description | Default |
|---|---|---|
KUBIYA_API_KEY | API key for authentication | None |
KUBIYA_BASE_URL | API base URL | https://api.kubiya.ai |
Constants
LLM Models
Available LLM models for agents:"claude-sonnet-4"(recommended)"claude-opus-4""claude-haiku-4"
Runners
"kubiya-hosted"- Default Kubiya-hosted runner- Custom runners created via the platform