Skip to main content

Python library to interact with Stackspot Agents API

Project description

stackclient

PyPI version

A simple Python client for interacting with StackSpot public Agents API.
Handles authentication (OAuth2 client credentials) and allows you to send prompts to StackSpot agents.


Features

  • Authenticate with StackSpot using OAuth2 client credentials.
  • Send prompts to any StackSpot agent and receive responses.
  • Minimal dependencies (urllib3).

Installation

Install from PyPI:

pip install stackclient

Usage

1. Import and Initialize

You can provide credentials directly or via environment variables:

  • STACKSPOT_CLIENT_ID
  • STACKSPOT_CLIENT_SECRET
  • STACKSPOT_REALM
  • STACKSPOT_AGENT_ID (optional, can be set per call)
from stackclient.client import StackSpotAgentClient

# Option 1: Pass credentials directly
client = StackSpotAgentClient(
    realm="your-realm",
    client_id="your-client-id",
    client_secret="your-client-secret",
    agent_id="your-agent-id"  # optional, can be set per call
)

# Option 2: Use environment variables
# export STACKSPOT_CLIENT_ID=your-client-id
# export STACKSPOT_CLIENT_SECRET=your-client-secret
# export STACKSPOT_REALM=your-realm
# export STACKSPOT_AGENT_ID=your-agent-id
client = StackSpotAgentClient()

2. Call an Agent

try:
    response = client.call_agent("Hello, StackSpot agent!")
    print(response)
except Exception as e:
    print(f"Error: {e}")

You can override the default agent ID per call:

response = client.call_agent("Prompt for another agent", agent_id="another-agent-id")

Exception Handling

  • AuthenticationError: Raised if authentication fails.
  • AgentCallError: Raised if the agent call fails.
  • MissingCredentialsError: Raised if required credentials are missing.
  • MissingAgentIDError: Raised if no agent ID is provided.

Requirements

  • Python 3.7+
  • urllib3>=2.5.0

License

MIT


Example

from stackclient.client import StackSpotAgentClient

client = StackSpotAgentClient(
    realm="myrealm",
    client_id="myclientid",
    client_secret="mysecret",
    agent_id="myagentid"
)
result = client.call_agent("What is StackSpot?")
print(result)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stackclient-0.2.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stackclient-0.2.4-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file stackclient-0.2.4.tar.gz.

File metadata

  • Download URL: stackclient-0.2.4.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for stackclient-0.2.4.tar.gz
Algorithm Hash digest
SHA256 1e25ecad82846fa15c72b140376a8ea923f56d5342079522486da586e38a40bc
MD5 aca99fbffbfea3c58558967b1c1b8e0b
BLAKE2b-256 59a3bee11d9a5ecb3ee6fbddc43e5613df8c1cec6e7ccd6c7e0aac07b1039f12

See more details on using hashes here.

Provenance

The following attestation bundles were made for stackclient-0.2.4.tar.gz:

Publisher: deploy.yml on riannselegar/stackclient

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stackclient-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: stackclient-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for stackclient-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 154feb44f930728edc9c31e57dab9b317471d840fbf3aee40a275f6512067c5c
MD5 7835c339e16408ca4185aa733a18a459
BLAKE2b-256 5d592594e52f35d1e9281eaac9ca2f2b866dc12abf90d3f03a00add4d97cd734

See more details on using hashes here.

Provenance

The following attestation bundles were made for stackclient-0.2.4-py3-none-any.whl:

Publisher: deploy.yml on riannselegar/stackclient

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page