MCPcopy Index your code
hub / github.com/coder/coder / AIProvider

Method AIProvider

codersdk/aiproviders.go:426–437  ·  view source on GitHub ↗

AIProvider fetches a single AI provider by ID or name.

(ctx context.Context, idOrName string)

Source from the content-addressed store, hash-verified

424
425// AIProvider fetches a single AI provider by ID or name.
426func (c *Client) AIProvider(ctx context.Context, idOrName string) (AIProvider, error) {
427 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/ai/providers/%s", idOrName), nil)
428 if err != nil {
429 return AIProvider{}, err
430 }
431 defer res.Body.Close()
432 if res.StatusCode != http.StatusOK {
433 return AIProvider{}, ReadBodyAsError(res)
434 }
435 var provider AIProvider
436 return provider, json.NewDecoder(res.Body).Decode(&provider)
437}
438
439// CreateAIProvider creates a new AI provider.
440func (c *Client) CreateAIProvider(ctx context.Context, req CreateAIProviderRequest) (AIProvider, error) {

Callers 2

TestAIProvidersCRUDFunction · 0.80

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by 2

TestAIProvidersCRUDFunction · 0.64