Skip to main content

A Python SDK for Inference Gateway

Project description

Inference Gateway Python SDK

An SDK written in Python for the Inference Gateway.

Installation

pip install inference-gateway

Usage

Creating a Client

from inference_gateway.client import InferenceGatewayClient, Provider

client = InferenceGatewayClient("http://localhost:8080")

# With authentication token(optional)
client = InferenceGatewayClient("http://localhost:8080", token="your-token")

Listing Models

To list available models, use the list_models method:

models = client.list_models()
print("Available models:", models)

Generating Content

To generate content using a model, use the generate_content method:

from inference_gateway.client import Provider, Role, Message

messages = [
    Message(Role.SYSTEM, "You are a helpful assistant"),
    Message(Role.USER, "Hello!"),
]

response = client.generate_content(
    provider=Provider.OPENAI,
    model="gpt-4",
    messages=messages
)
print("Assistant:", response["choices"][0]["message"]["content"])

Health Check

To check the health of the API, use the health_check method:

is_healthy = client.health_check()
print("API Status:", "Healthy" if is_healthy else "Unhealthy")

License

This SDK is distributed under the MIT License, see LICENSE for more information.

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

inference_gateway-0.2.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

inference_gateway-0.2.3-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: inference_gateway-0.2.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for inference_gateway-0.2.3.tar.gz
Algorithm Hash digest
SHA256 063870f1fecbf6ce8a54040eaeb01c8cc07d08663ed8fcc65faeec4add55cff6
MD5 695333387085b0ce787b37cddf1097b6
BLAKE2b-256 825a51cd1e12846220754d857ebfd5c413276558474fe237f1ae763b4bd08de8

See more details on using hashes here.

File details

Details for the file inference_gateway-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for inference_gateway-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3fe9e339a1790c4cfdfe1e3db9e841144181535b7de409461c4d6a72807c5ce4
MD5 9d038b1cc90c424911766579738f2606
BLAKE2b-256 38e4e2a6881663c86eccfc0b049dd25c41aaf43ee96064dd6f41d30390e553fd

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