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.3.tar.gz (4.6 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.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stackclient-0.2.3.tar.gz
  • Upload date:
  • Size: 4.6 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.3.tar.gz
Algorithm Hash digest
SHA256 0a1e074e2cdd51419260a510754d860fe584f153a456a4c64153492cd3cec09d
MD5 ab6e837023e03f402d65c0a2345613c8
BLAKE2b-256 af1eadf89bdfdb29c29562dd2e748f45c6143b31b561c0f0fa887f353ce3ec9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for stackclient-0.2.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: stackclient-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 5.4 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c6b431bd8f6b32304f2e0e456aea18d9a66f4f398590bbe53572b4f388814e6e
MD5 5a9f639e51ee0bc7f3374d9cb539e479
BLAKE2b-256 fe6b430a31e431c80da5c13c0c15486ebfe277d2951a19b8a1015ffa27a18f73

See more details on using hashes here.

Provenance

The following attestation bundles were made for stackclient-0.2.3-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