MCPcopy Create free account
hub / github.com/coder/aibridge / NewOpenAI

Function NewOpenAI

provider/openai.go:41–62  ·  view source on GitHub ↗
(cfg config.OpenAI)

Source from the content-addressed store, hash-verified

39var _ Provider = &OpenAI{}
40
41func NewOpenAI(cfg config.OpenAI) *OpenAI {
42 if cfg.Name == "" {
43 cfg.Name = config.ProviderOpenAI
44 }
45 if cfg.BaseURL == "" {
46 cfg.BaseURL = "https://api.openai.com/v1/"
47 }
48 if cfg.Key == "" {
49 cfg.Key = os.Getenv("OPENAI_API_KEY")
50 }
51 if cfg.APIDumpDir == "" {
52 cfg.APIDumpDir = os.Getenv("BRIDGE_DUMP_DIR")
53 }
54 if cfg.CircuitBreaker != nil {
55 cfg.CircuitBreaker.OpenErrorResponse = openAIOpenErrorResponse
56 }
57
58 return &OpenAI{
59 cfg: cfg,
60 circuitBreaker: cfg.CircuitBreaker,
61 }
62}
63
64func (*OpenAI) Type() string {
65 return config.ProviderOpenAI

Callers 14

NewOpenAIProviderFunction · 0.92
TestAPIDumpFunction · 0.92
TestAPIDumpPassthroughFunction · 0.92
newDefaultProviderFunction · 0.92
TestActorHeadersFunction · 0.92
TestOpenAI_TypeAndNameFunction · 0.85

Calls

no outgoing calls