Quickstart
This page shows how to send your first request to a shared model.
Before you start#
You must have a Nuemetrix account and an organization. The sign-up page makes the organization for you.
Procedure#
- Sign in to the dashboard.
- Go to API keys.
- Select Create key.
- Type a name, for example
quickstart. - Select the scope
inferenceand select Create. - Copy the key. The dashboard shows the key only one time.
- Set two environment variables in your shell.
export EMBER_API_URL="<the API URL of your Nuemetrix installation>"
export EMBER_API_KEY="<your key>"
- Send a request. Choose your language.
curl "$EMBER_API_URL/v1/chat/completions" \
-H "Authorization: Bearer $EMBER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<model ID>",
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"temperature": 0.7,
"max_tokens": 256
}'
import os
from openai import OpenAI
client = OpenAI(
base_url=os.environ["EMBER_API_URL"] + "/v1",
api_key=os.environ["EMBER_API_KEY"],
)
reply = client.chat.completions.create(
model="<model ID>",
messages=[
{
"role": "user",
"content": "Hello"
}
],
temperature=0.7,
max_tokens=256,
)
print(reply.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: `${process.env["EMBER_API_URL"]}/v1`,
apiKey: process.env["EMBER_API_KEY"],
});
const reply = await client.chat.completions.create({
model: "<model ID>",
messages: [
{
role: "user",
content: "Hello",
},
],
temperature: 0.7,
max_tokens: 256,
});
console.log(reply.choices[0]?.message.content);
// Cargo.toml:
// reqwest = { version = "0.13", features = ["json"] }
// serde_json = "1"
// tokio = { version = "1", features = ["full"] }
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let url = std::env::var("EMBER_API_URL")?;
let key = std::env::var("EMBER_API_KEY")?;
let body = json!({
"model": "<model ID>",
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"temperature": 0.7,
"max_tokens": 256
});
let response = reqwest::Client::new()
.post(format!("{url}/v1/chat/completions"))
.bearer_auth(key)
.json(&body)
.send()
.await?
.error_for_status()?;
let reply: serde_json::Value = response.json().await?;
println!("{}", reply["choices"][0]["message"]["content"].as_str().unwrap_or(""));
Ok(())
}
To find the model IDs, send GET /v1/models with the same key.
Use an SDK#
The Python and TypeScript samples use the OpenAI SDK. Change only the base URL and the API key. The Rust sample uses reqwest. See SDK clients for more.