Quick Start
Authentication
The Neyra AI API employs API keys for authentication. You can generate API keys either at a user level or for service accounts. Each API key can be restricted to specific scopes, allowing for tailored access control.
Get your API keys
Your API requests are authenticated using API keys. Any request that doesn't include an API key will return an error. You can generate an API key from your Dashboard.
All API requests should include your API key in an Authorization HTTP header as follows:
Authorization: Bearer NEYRA_API_KEYInstall the library
Our platform utilizes the OpenAI libraries to make the interaction as easy as possible. The best way to interact with our API is to use the official libraries:
# Install via pip
pip install openai# Install via NPM
npm install --save openaifrom openai import OpenAI
from os import getenv
# gets API Key from environment variable NEYRA_API_KEY
client = OpenAI(
base_url="https://api.neyratech.com/api/v1",
api_key=getenv("NEYRA_API_KEY"),
)
completion = client.chat.completions.create(
model="neyra/1D",
stream=True,
messages=[
{
"role": "user",
"content": "Hi",
},
],
)
for chunk in completion:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="")Create new conversation
POST https://api.neyratech.com/v1/chat/completions
Creates a new conversation.
Request Body
messages*
array
A list of messages comprising the conversation so far.
model*
string
ID of the model to use.
stream
bool
If set, partial message deltas will be sent
stop
string / array
Up to 10 sequences where the API will stop generating further tokens.
max_tokens
integer
The maximum number of tokens that can be generated in the chat completion.
temperature
float
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
top_p
float
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
Last updated