Skip to content

[Docs] [compat-oai] Incorrect example initialization code for OpenAI #3369

@Tyg-g

Description

@Tyg-g

Is your report related to a problem? Please describe.

I believe the readme contains incorrect or incomplete initialization code:

import dotenv from 'dotenv';
import { genkit } from 'genkit';
import openAI, { gpt35Turbo } from '@genkit-ai/compat-oai';

dotenv.config();

const ai = genkit({
  plugins: [openAI({ apiKey: process.env.OPENAI_API_KEY })],
  // specify a default model if not provided in generate params:
  model: gpt35Turbo,
});

As it throws the error:

TypeError: Cannot read properties of undefined (reading 'name')
    at openAICompatible (file:///{project}/node_modules/@genkit-ai/compat-oai/lib/index.mjs:7:13)

Is your report related to a suggestion/improvement? Please describe.

To use the OpenAI models, the import line should look like this:

import openAI from '@genkit-ai/compat-oai/openai';

Additional context
None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsImprovements or additions to documentation

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions