Token.js
GitHubDiscordFeedback
  • Token.js
  • Providers
    • AI21
    • Anthropic
    • Bedrock
    • Cohere
    • Gemini
    • Groq
    • Mistral
    • OpenAI
    • OpenRouter
    • Perplexity
    • OpenAI Compatible
  • Contact Us
  • Contributing
Powered by GitBook
On this page
  • Usage
  • Supported Models
  • Legend
  • Additional Resources

Was this helpful?

Edit on GitHub
  1. Providers

OpenAI

PreviousMistralNextOpenRouter

Last updated 18 days ago

Was this helpful?

Usage

.env
OPENAI_API_KEY=
import { TokenJS } from 'token.js'

// Create the Token.js client
const tokenjs = new TokenJS()

async function main() {
  // Create a model response
  const completion = await tokenjs.chat.completions.create({
    // Specify the provider and model
    provider: 'openai',
    model: 'gpt-4o',
    // Define your message
    messages: [
      {
        role: 'user',
        content: 'Hello!',
      },
    ],
  })
  console.log(completion.choices[0])
}
main()

Supported Models

Model
Chat Completion
Streaming
JSON Output
Image Input
Function Calling
N > 1

gpt-4.5-preview

✅

✅

✅

✅

✅

✅

gpt-4.5-preview-2025-02-27

✅

✅

✅

✅

✅

✅

gpt-4.1

✅

✅

✅

✅

✅

✅

gpt-4.1-2025-04-14

✅

✅

✅

✅

✅

✅

gpt-4o

✅

✅

✅

✅

✅

✅

gpt-4o-mini

✅

✅

✅

✅

✅

✅

gpt-4o-2024-05-13

✅

✅

✅

✅

✅

✅

gpt-4o-2024-08-06

✅

✅

✅

✅

✅

✅

gpt-4-turbo

✅

✅

✅

✅

✅

✅

gpt-4-turbo-2024-04-09

✅

✅

✅

✅

✅

✅

gpt-4-0125-preview

✅

✅

✅

✅

✅

✅

gpt-4-turbo-preview

✅

✅

✅

✅

✅

✅

gpt-4-1106-preview

✅

✅

✅

✅

✅

✅

gpt-4-vision-preview

✅

✅

✅

✅

➖

✅

gpt-4

✅

✅

➖

➖

✅

✅

gpt-4-0314

✅

✅

➖

➖

➖

✅

gpt-4-0613

✅

✅

➖

➖

✅

✅

gpt-4-32k

✅

✅

➖

➖

➖

✅

gpt-4-32k-0314

✅

✅

➖

➖

➖

✅

gpt-4-32k-0613

✅

✅

➖

➖

➖

✅

gpt-3.5-turbo

✅

✅

✅

➖

✅

✅

gpt-3.5-turbo-16k

✅

✅

➖

➖

➖

✅

gpt-3.5-turbo-0301

✅

✅

➖

➖

➖

✅

gpt-3.5-turbo-0613

✅

✅

➖

➖

✅

✅

gpt-3.5-turbo-1106

✅

✅

✅

➖

✅

✅

gpt-3.5-turbo-0125

✅

✅

✅

➖

✅

✅

gpt-3.5-turbo-16k-0613

✅

✅

➖

➖

➖

✅

o3-mini

✅

✅

✅

➖

✅

✅

o1-mini

✅

➖

➖

➖

➖

✅

o1-mini-2024-09-12

✅

➖

➖

➖

➖

✅

o1-preview

✅

➖

➖

➖

➖

✅

o1-preview-2024-09-12

✅

➖

➖

➖

➖

✅

Legend

Symbol
Description

Supported by Token.js

Not supported by the LLM provider, so Token.js cannot support it

Additional Resources

Get an OpenAI API key
OpenAI Documentation
✅
➖