UpsertUserChatProviderKey creates or replaces a user API key for a provider.
(ctx context.Context, providerID uuid.UUID, req CreateUserChatProviderKeyRequest)
| 2211 | |
| 2212 | // UpsertUserChatProviderKey creates or replaces a user API key for a provider. |
| 2213 | func (c *ExperimentalClient) UpsertUserChatProviderKey(ctx context.Context, providerID uuid.UUID, req CreateUserChatProviderKeyRequest) (UserChatProviderConfig, error) { |
| 2214 | res, err := c.Request(ctx, http.MethodPut, fmt.Sprintf("/api/experimental/chats/user-provider-configs/%s", providerID), req) |
| 2215 | if err != nil { |
| 2216 | return UserChatProviderConfig{}, xerrors.Errorf("upsert user chat provider key: %w", err) |
| 2217 | } |
| 2218 | defer res.Body.Close() |
| 2219 | if res.StatusCode != http.StatusOK { |
| 2220 | return UserChatProviderConfig{}, ReadBodyAsError(res) |
| 2221 | } |
| 2222 | var config UserChatProviderConfig |
| 2223 | return config, json.NewDecoder(res.Body).Decode(&config) |
| 2224 | } |
| 2225 | |
| 2226 | // DeleteUserChatProviderKey deletes a user API key for a provider. |
| 2227 | func (c *ExperimentalClient) DeleteUserChatProviderKey(ctx context.Context, providerID uuid.UUID) error { |