Logo
TexAPI/Docs
Getting StartedQuickstart

Quickstart

Get your first AI API response in under 5 minutes. TexAPI is a drop-in compatible gateway — if you're using the OpenAI SDK, you only need to change the base URL and API key.

OpenAI SDK Compatible

TexAPI implements the OpenAI API specification. Most OpenAI SDK code works without modification — just update your baseURL and apiKey.

1. Install the SDK

bash
npm install openai
# or
pip install openai

2. Set your API key

.env
TEXAPI_KEY=txk_live_your_api_key_here

3. Make your first request

Node.jsPythoncurl
example.ts
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.TEXAPI_KEY,
  baseURL: 'https://texapi.dev/v1',
});

const response = await client.chat.completions.create({
  model: 'gpt-5.4-mini',
  messages: [
    { role: 'user', content: 'Explain what an API gateway does in 2 sentences.' }
  ],
});

console.log(response.choices[0].message.content);
console.log('Tokens used:', response.usage.total_tokens);
console.log('Credits:', response.usage.credits);

4. Expected response

json
{
  "id": "chatcmpl-texapi-8f2a3b1c",
  "object": "chat.completion",
  "created": 1746154547,
  "model": "gpt-5.4-mini",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "An API gateway acts as a single entry point for client requests, routing them to the appropriate backend services. It handles cross-cutting concerns like authentication, rate limiting, and load balancing."
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 42,
    "total_tokens": 60,
    "credits": 0.00042
  },
  "texapi": {
    "gateway_latency_ms": 11,
    "total_latency_ms": 82,
    "cache_hit": false
  }
}

Never expose your API key in client-side JavaScript. Always use environment variables and server-side code for API calls.