Documentation
¶
Index ¶
- Constants
- Variables
- func PrepareVertexAnthropicBody(body []byte) ([]byte, error)
- type AnthropicAuthMode
- type AnthropicClient
- type AnthropicForwardRequest
- type AnthropicVertexClient
- type AnthropicVertexForwardRequest
- type ChatCompletionsClient
- type ChatForwardRequest
- type ChatGPTClient
- type ClaudeProfile
- type ClaudeToken
- type ClaudeUsage
- type Credential
- type ForwardRequest
- type OpenAIClient
- type OpenAIForwardRequest
- type Token
- type TokenError
- type VertexAnthropicConfig
- type VertexAnthropicStatus
- type VertexTokenSource
- type WhamError
- type WhamUsage
Constants ¶
View Source
const ( AnthropicMessagesURL = "https://api.anthropic.com/v1/messages" AnthropicVersionHeader = "2023-06-01" ClaudeOAuthBetaHeader = "oauth-2025-04-20" )
View Source
const ( ChatGPTResponsesURL = "https://chatgpt.com/backend-api/codex/responses" ChatGPTResponsesCompactURL = "https://chatgpt.com/backend-api/codex/responses/compact" ChatGPTUsageURL = "https://chatgpt.com/backend-api/wham/usage" ChatGPTAccountCheckURL = "https://chatgpt.com/backend-api/wham/accounts/check" )
View Source
const ( ClaudeTokenURL = "https://console.anthropic.com/v1/oauth/token" ClaudeClientID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e" )
View Source
const ( VertexAnthropicVersion = "vertex-2023-10-16" VertexCloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform" )
View Source
const ClaudeUsageURL = "https://api.anthropic.com/api/oauth/usage"
View Source
const OpenAIChatURL = "https://api.openai.com/v1/chat/completions"
View Source
const OpenAIResponsesURL = "https://api.openai.com/v1/responses"
Variables ¶
View Source
var ClaudeTokenURLOverride string
View Source
var ClaudeUsageURLOverride string
Functions ¶
Types ¶
type AnthropicAuthMode ¶
type AnthropicAuthMode string
const ( AnthropicAuthAPIKey AnthropicAuthMode = "api-key" AnthropicAuthOAuth AnthropicAuthMode = "oauth" )
type AnthropicClient ¶
func NewAnthropicClient ¶
func NewAnthropicClient() *AnthropicClient
func (*AnthropicClient) Forward ¶
func (c *AnthropicClient) Forward(ctx context.Context, req AnthropicForwardRequest) (*http.Response, error)
type AnthropicForwardRequest ¶
type AnthropicVertexClient ¶
type AnthropicVertexClient struct {
HTTPClient *http.Client
BaseURL string
Config VertexAnthropicConfig
TokenSource VertexTokenSource
}
func NewAnthropicVertexClient ¶
func NewAnthropicVertexClient(ctx context.Context, overrides ...VertexAnthropicConfig) *AnthropicVertexClient
func (*AnthropicVertexClient) Forward ¶
func (c *AnthropicVertexClient) Forward(ctx context.Context, req AnthropicVertexForwardRequest) (*http.Response, error)
func (*AnthropicVertexClient) Status ¶
func (c *AnthropicVertexClient) Status(ctx context.Context) VertexAnthropicStatus
type ChatCompletionsClient ¶
func NewChatCompletionsClient ¶
func NewChatCompletionsClient() *ChatCompletionsClient
func (*ChatCompletionsClient) Forward ¶
func (c *ChatCompletionsClient) Forward(ctx context.Context, req ChatForwardRequest) (*http.Response, error)
type ChatForwardRequest ¶
type ChatGPTClient ¶
type ChatGPTClient struct {
HTTPClient *http.Client
WhamHTTPClient *http.Client
BaseURL string
CompactURL string
UsageURL string
}
func NewChatGPTClient ¶
func NewChatGPTClient() *ChatGPTClient
func (*ChatGPTClient) FetchUsage ¶
func (c *ChatGPTClient) FetchUsage(ctx context.Context, cred Credential) (WhamUsage, error)
func (*ChatGPTClient) Forward ¶
func (c *ChatGPTClient) Forward(ctx context.Context, req ForwardRequest) (*http.Response, error)
type ClaudeProfile ¶
type ClaudeProfile struct {
Email string
AccountID string
SubscriptionType string
RateLimitTier string
}
func GetClaudeProfile ¶
func GetClaudeProfile(ctx context.Context, accessToken string) (ClaudeProfile, error)
type ClaudeToken ¶
type ClaudeToken struct {
AccessToken string
RefreshToken string
ExpiresIn int
ExpiresAt time.Time
}
func ExchangeClaudeCode ¶
func ExchangeClaudeCode(ctx context.Context, code, verifier, redirectURI, state string) (ClaudeToken, error)
func RefreshClaudeToken ¶
func RefreshClaudeToken(ctx context.Context, refreshToken string) (ClaudeToken, error)
type ClaudeUsage ¶
type ClaudeUsage struct {
PrimaryUsedPct float64
SecondaryUsedPct float64
PrimaryResetAt time.Time
SecondaryResetAt time.Time
}
func GetClaudeUsage ¶
func GetClaudeUsage(ctx context.Context, accessToken string) (ClaudeUsage, error)
type Credential ¶
type ForwardRequest ¶
type OpenAIClient ¶
func NewOpenAIClient ¶
func NewOpenAIClient() *OpenAIClient
func (*OpenAIClient) Forward ¶
func (c *OpenAIClient) Forward(ctx context.Context, req OpenAIForwardRequest) (*http.Response, error)
type OpenAIForwardRequest ¶
type Token ¶
type Token struct {
AccessToken string
RefreshToken string
IDToken string
ExpiresIn int
ExpiresAt time.Time
}
func ExchangeOpenAICode ¶
type TokenError ¶
func (*TokenError) Error ¶
func (e *TokenError) Error() string
type VertexAnthropicConfig ¶
type VertexAnthropicConfig struct {
ProjectID string `json:"project_id"`
Location string `json:"location"`
CredentialsFile string `json:"-"`
AuthMethod string `json:"auth_method,omitempty"`
}
func DetectVertexAnthropicConfig ¶
func DetectVertexAnthropicConfig() VertexAnthropicConfig
type VertexAnthropicStatus ¶
type VertexTokenSource ¶
func DefaultVertexTokenSource ¶
func DefaultVertexTokenSource(ctx context.Context, credentialsFile ...string) (VertexTokenSource, string)
Click to show internal directories.
Click to hide internal directories.