@@ -30,7 +30,6 @@ type OpenAIProvider struct {
30
30
// OpenAIProviderModel describes the provider data model.
31
31
type OpenAIProviderModel struct {
32
32
BaseUrl types.String `tfsdk:"base_url"`
33
- ApiKey types.String `tfsdk:"api_key"`
34
33
SessionKey types.String `tfsdk:"session_key"`
35
34
}
36
35
@@ -46,11 +45,6 @@ func (p *OpenAIProvider) Schema(ctx context.Context, req provider.SchemaRequest,
46
45
MarkdownDescription : "Base URL for the OpenAI API. Defaults to `https://api.openai.com`." ,
47
46
Optional : true ,
48
47
},
49
- "api_key" : schema.StringAttribute {
50
- MarkdownDescription : "API key for the OpenAI API." ,
51
- Optional : true ,
52
- Sensitive : true ,
53
- },
54
48
"session_key" : schema.StringAttribute {
55
49
MarkdownDescription : "Session key for the OpenAI API." ,
56
50
Optional : true ,
@@ -76,21 +70,6 @@ func (p *OpenAIProvider) Configure(ctx context.Context, req provider.ConfigureRe
76
70
baseUrl = "https://api.openai.com"
77
71
}
78
72
79
- var apiKey string
80
- if ! data .ApiKey .IsNull () {
81
- apiKey = data .ApiKey .ValueString ()
82
- } else if v := os .Getenv ("OPENAI_API_KEY" ); v != "" {
83
- apiKey = v
84
- }
85
-
86
- if apiKey == "" {
87
- resp .Diagnostics .AddError ("api_key is required" , "api_key is required" )
88
- return
89
- } else if ! strings .HasPrefix (apiKey , "sk-" ) {
90
- resp .Diagnostics .AddError ("api_key must start with 'sk-'" , "api_key must start with 'sk-'" )
91
- return
92
- }
93
-
94
73
var sessionKey string
95
74
if ! data .SessionKey .IsNull () {
96
75
sessionKey = data .SessionKey .ValueString ()
@@ -109,12 +88,7 @@ func (p *OpenAIProvider) Configure(ctx context.Context, req provider.ConfigureRe
109
88
client , err := apiclient .NewClientWithResponses (
110
89
baseUrl ,
111
90
apiclient .WithRequestEditorFn (func (ctx context.Context , req * http.Request ) error {
112
- if strings .HasPrefix (req .URL .Path , "/v1" ) {
113
- req .Header .Set ("Authorization" , "Bearer " + apiKey )
114
- } else if strings .HasPrefix (req .URL .Path , "/dashboard" ) {
115
- req .Header .Set ("Authorization" , "Bearer " + sessionKey )
116
- }
117
-
91
+ req .Header .Set ("Authorization" , "Bearer " + sessionKey )
118
92
return nil
119
93
}),
120
94
)
0 commit comments