Elektric
Docs

Quickstart

Connect once, then choose a model with Wire or let Grid choose for you.

#1. Prerequisites

  • An Elektric account
  • An Elektric API key
  • Node.js 18+

#2. Create an API key

Create one under the dashboard’s API Keys tab. Save it as ELEKTRIC_API_KEY in your server environment. The secret is shown once.

#3. Install

Shell
npm install elektric-ai

#4. Grid — Elektric chooses the model

Grid selects an eligible model for the request. Grid currently uses the API model identifier elektric-grid.

TypeScript
import { Elektric } from "elektric-ai";

const elektric = new Elektric({ apiKey: process.env.ELEKTRIC_API_KEY! });
const response = await elektric.chat({
  model: "elektric-grid",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(response.message);

#5. Wire — You choose the model

Use Wire when you already know the model you want. This example uses the public ID gpt-6-astra; discover current IDs with GET /v1/models.

TypeScript
const response = await elektric.chat({
  model: "gpt-6-astra",
  messages: [{ role: "user", content: "Hello" }],
});

#Expected result

The assistant response is printed, and the response includes a Request ID.

#What Elektric handled

For Grid, Elektric authenticated the request, selected an eligible model, returned a normalized response, and recorded usage and cost.

For Wire, Elektric used the exact public model ID you provided instead of routing the request.