Quickstart

This guide walks you through making your first AI model request with the Teklrn AI Gateway. While this guide focuses on the Vercel AI SDK, you can also use the OpenAI SDK, Python, or cURL.

Prerequisites

You need a Teklrn account with API credits. Sign up at teklrn.ai and add credits from your account dashboard.

Using the Vercel AI SDK

1. Create your project

mkdir my-ai-app
cd my-ai-app
npm init -y

2. Install dependencies

npm install ai @ai-sdk/openai dotenv

3. Set up your API key

Create a .env file and add your Teklrn API key:

Teklrn_API_KEY=your_api_key_here

For step-by-step instructions on getting an API key, please see the Teklrn Gateway API Key instructions.

4. Create and run your script

Create an index.mjs file:

import { streamText } from "ai"
import { createOpenAI } from "@ai-sdk/openai"
import "dotenv/config"

const teklrn = createOpenAI({
  baseURL: "https://ai-gateway.Teklrn.ai/api/v1",
  apiKey: process.env.Teklrn_API_KEY,
})

async function main() {
  const result = streamText({
    model: teklrn.chat("anthropic/claude-sonnet-4.5"),
    prompt: "Invent a new holiday and describe its traditions.",
  })

  for await (const textPart of result.textStream) {
    process.stdout.write(textPart)
  }

  console.log()
  console.log("Token usage:", await result.usage)
  console.log("Finish reason:", await result.finishReason)
}

main().catch(console.error)

Run the script:

node index.mjs

You should see the model's response streamed to your terminal.

Using the OpenAI SDK

The Teklrn AI Gateway is fully OpenAI-compatible, so you can use the OpenAI SDK by pointing it to the Teklrn base URL.

import OpenAI from "openai"

const client = new OpenAI({
  apiKey: process.env.Teklrn_API_KEY,
  baseURL: "https://ai-gateway.Teklrn.ai/api/v1",
})

const response = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4.5",
  messages: [{ role: "user", content: "Why is the sky blue?" }],
})

console.log(response.choices[0].message.content)

Using cURL

curl -X POST "https://ai-gateway.Teklrn.ai/api/v1/chat/completions" \
  -H "Authorization: Bearer $Teklrn_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "messages": [
      {
        "role": "user",
        "content": "Why is the sky blue?"
      }
    ],
    "stream": false
  }'

Next steps