Skip to content

[Go] OpenAI invalid model ID #3584

@gvozdevs

Description

@gvozdevs

Describe the bug
When using OpenAI embedding models, I get an error when executing:

POST "https://api.openai.com/v1/embeddings": 400 Bad Request {
        "message": "invalid model ID",
        "type": "invalid_request_error",
        "param": null,
        "code": null
}

To Reproduce

package main

import (
	"context"
	"log"

	"github.com/firebase/genkit/go/ai"
	"github.com/firebase/genkit/go/genkit"
	"github.com/firebase/genkit/go/plugins/compat_oai/openai"
)

func main() {
	ctx := context.Background()
	oai := &openai.OpenAI{}
	gk := genkit.Init(ctx, genkit.WithPlugins(oai))
	em := oai.Embedder(gk, "openai/text-embedding-3-small")
	if em == nil {
		log.Fatal("failed to create embedder")
	}

	dc := ai.DocumentFromText("hello", nil)
	er := &ai.EmbedRequest{
		Input:   []*ai.Document{dc},
		Options: nil,
	}
	rp, err := em.Embed(ctx, er)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("%+v", rp)
}

Expected behavior
Successful embedding

Runtime (please complete the following information):

  • OS: MacOS
  • Version 15.6.1

** Go version
go version go1.25.0 darwin/arm64

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggo

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions