Skip to main content

Introducing the GravixLayer Python SDK

The GravixLayer Python SDK is a client library that allows you to interact with the GravixLayer API using Python. It provides a simple and intuitive interface for working with language models through an OpenAI-compatible API.

The SDK is designed to be familiar to developers already using OpenAI's client libraries, making it easy to integrate GravixLayer into existing applications.

info

Public Preview: Gravix Layer is currently in public preview. Ongoing updates to API endpoints and models are happening, and it is available to try for free.

Installation

You can install the GravixLayer Python SDK using pip:

pip install gravixlayer

Make sure to set the GRAVIXLAYER_API_KEY environment variable to your GravixLayer API key:

export GRAVIXLAYER_API_KEY=<API_KEY>

You can create an API key in the GravixLayer web UI or contact support to get started.

Quick Start

Here's a simple example to get you started:

import os
from gravixlayer import GravixLayer

# Make sure to set your API key in the terminal before running this script:
# export GRAVIXLAYER_API_KEY=<API_KEY>

client = GravixLayer()

response = client.chat.completions.create(
model="meta-llama/llama-3.1-8b-instruct",
messages=[{"role": "user", "content": "Hello, world!"}]
)

print(response.choices[0].message.content)

Next Steps

Get started by learning about the basics of working with the GravixLayer SDK. Or, if you'd prefer to jump straight in, we have prepared an interactive tutorial.