Skip to main content

Python SDK for the Mesh API with improved authentication

Project description

Mesh SDK for Python

The Mesh SDK is a Python client library for the Mesh API. It provides a simple interface for authenticating with the API and making requests to the various endpoints.

Installation

You can install the Mesh SDK from PyPI:

pip install mesh-sdk

Or directly from this repository:

pip install git+https://github.com/meshapi/mesh-sdk.git

Features

  • Easy authentication with OAuth 2.0 flows
  • Automatic token refresh
  • Both browser-based and headless device flow authentication
  • Secure token storage using system keychain
  • Comprehensive error handling
  • Simple interface for chat completions with various AI models

Usage

Basic Usage

from mesh_sdk import MeshClient

# Create a client (will automatically handle authentication if needed)
client = MeshClient()

# Send a chat message
response = client.chat("Hello, how are you today?", model="claude-3-7-sonnet")
print(response)

Authentication

Authentication is handled automatically when needed. However, you can explicitly authenticate:

from mesh_sdk import auth

# Trigger browser-based authentication
token_data = auth.authenticate()

# Or use headless/device flow authentication
token_data = auth.authenticate(headless=True)

You can also use the CLI tool for authentication:

# Authenticate using browser-based flow
mesh-auth

# Show help
mesh-auth --help

Using the AutoRefreshMeshClient

The AutoRefreshMeshClient automatically refreshes expired tokens and manages token persistence:

from mesh_sdk import AutoRefreshMeshClient

# Create client with auto-refresh enabled
client = AutoRefreshMeshClient()

# Use just like regular MeshClient
response = client.chat("Hello!", model="gpt-4o")
print(response)

Development

To set up a development environment:

# Clone the repository
git clone https://github.com/meshapi/mesh-sdk.git
cd mesh-sdk/sdk/python/mesh_sdk_package

# Create a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install the package in development mode
pip install -e .

# Run tests
python -m test_auth_module config

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

mesh_sdk-1.3.1.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

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

mesh_sdk-1.3.1-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file mesh_sdk-1.3.1.tar.gz.

File metadata

  • Download URL: mesh_sdk-1.3.1.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mesh_sdk-1.3.1.tar.gz
Algorithm Hash digest
SHA256 0b0a0cbc8e6a4f66c8e04b1ad5c04a74267fa5f4f5fcd6d323fcef0de9d64bf5
MD5 3c33e3e219263cd653580585bbc10690
BLAKE2b-256 67893b0377a0f2ad52b69dbcf51c1d7fb65919b71383c61d9d68cdc86598b4af

See more details on using hashes here.

File details

Details for the file mesh_sdk-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: mesh_sdk-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mesh_sdk-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d50872d8bcb54ea9794ae288266f111e157c604de3950a7bed78f4df9c117b8
MD5 e41d408c151017e68a9db3a8901d7346
BLAKE2b-256 e8817af416bfbcd0a0011e6997bf50b3ef343fd3a95f3917d10fa4e3fa25465f

See more details on using hashes here.

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