Fetches model catalogs from OpenAI, Anthropic, Gemini, etc.
// Source: https://github.com/micro/go-micro | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
// Package catalog reads provider model catalogs without sharing credentials
// across origins or keeping a hard-coded model list.
package catalog
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
)
// List handles the OpenAI, Anthropic and Gemini catalog response formats.
func List(ctx context.Context, endpoint, key, format string) ([]string, error) {
ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
defer cancel()
client := &http.Client{CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
var n
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key