UpsertUserAIProviderKey creates or replaces a user API key for an AI provider.
(ctx context.Context, user string, providerID uuid.UUID, req CreateUserAIProviderKeyRequest)
| 2166 | |
| 2167 | // UpsertUserAIProviderKey creates or replaces a user API key for an AI provider. |
| 2168 | func (c *ExperimentalClient) UpsertUserAIProviderKey(ctx context.Context, user string, providerID uuid.UUID, req CreateUserAIProviderKeyRequest) (UserAIProviderKeyConfig, error) { |
| 2169 | res, err := c.Request(ctx, http.MethodPut, fmt.Sprintf("%s/%s", userAIProviderKeysPath(user), providerID), req) |
| 2170 | if err != nil { |
| 2171 | return UserAIProviderKeyConfig{}, xerrors.Errorf("upsert user AI provider key: %w", err) |
| 2172 | } |
| 2173 | defer res.Body.Close() |
| 2174 | if res.StatusCode != http.StatusOK { |
| 2175 | return UserAIProviderKeyConfig{}, ReadBodyAsError(res) |
| 2176 | } |
| 2177 | var config UserAIProviderKeyConfig |
| 2178 | return config, json.NewDecoder(res.Body).Decode(&config) |
| 2179 | } |
| 2180 | |
| 2181 | // DeleteUserAIProviderKey deletes a user API key for an AI provider. |
| 2182 | func (c *ExperimentalClient) DeleteUserAIProviderKey(ctx context.Context, user string, providerID uuid.UUID) error { |