Client SDKs

Guide on using client SDKs with our API.

We currently do not have our own client libraries. However, we've designed our chat completions endpoint to be directly compatible with OpenAI's, so you are able to use OpenAI's Python, Node.js, or third party client libraries with our API.

Using OpenAI's client SDKs

1

Install

Use OpenAI's official Python bindings, Node.js library, or a community maintained library.

pip install openai 
2

Override the base url in the client

from openai import OpenAI

client = OpenAI(api_key=$LUNE_API_KEY, base_url="https://api.trylune.ai")

completion = client.chat.completions.create(
model="tycho", 
messages=[
  {"role": "user", "content": "What is the format of the AIMessageChunk object in Langchain"}
],
stream=True
)

for chunk in completion:
  if chunk.choices[0].delta.content is not None:
      print(chunk.choices[0].delta.content, end='', flush=True)