How can I access the Typescript type for params of the API?

I’m trying to do something like:

export default async function getGptMessage(params: any) {
  try {
    const gptResponse = await;

I want to access the Typescript typing for what this functoin expects. Where can I access it? I could not find it.

The return object from the OpenAI chat completions API is documented in the API reference.

Streaming chunks are not fully documented, are different between chat and completion, and the return you process will depend on the library being used. You can just dump out a stream=True response and figure out how to handle a null initial chunk, delta contents, and finish reasons.

Here’s how you can do that:

import OpenAI from 'openai';

const openai = new OpenAI({
  apiKey: 'My API Key', // defaults to process.env["OPENAI_API_KEY"]

async function main() {
  const params: OpenAI.Chat.ChatCompletionCreateParams = {
    messages: [{ role: 'user', content: 'Say this is a test' }],
    model: 'gpt-3.5-turbo',
  const chatCompletion: OpenAI.Chat.ChatCompletion = await;




Awesome, thanks so much! I appreciate it.