api

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package api provides an HTTP client for the Kimi Code Console backend.

Package api provides Kimi Code Console API service wrappers.

Package api contains request/response types for the Kimi Code Console API.

Index

Constants

View Source
const (
	BaseURL = "https://www.kimi.com"
)

BaseURL is the Kimi Code Console API endpoint.

Variables

This section is empty.

Functions

func IsMock

func IsMock() bool

IsMock returns true when KIME_MOCK is set to a non-zero value.

Types

type Amount

type Amount struct {
	Currency     string `json:"currency"`
	PriceInCents string `json:"priceInCents"`
}

Amount is a price amount in a specific currency.

type Balance

type Balance struct {
	ID              string  `json:"id"`
	Feature         string  `json:"feature"`
	Type            string  `json:"type"`
	Unit            string  `json:"unit"`
	AmountUsedRatio float64 `json:"amountUsedRatio"`
	ExpireTime      string  `json:"expireTime"`
}

Balance shows usage ratio for a feature.

type BillingCycle

type BillingCycle struct {
	Duration int    `json:"duration"`
	TimeUnit string `json:"timeUnit"`
}

BillingCycle describes how often a plan renews.

type Capability

type Capability struct {
	Feature    string     `json:"feature"`
	Constraint Constraint `json:"constraint"`
}

Capability describes a feature and its constraint.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an HTTP client for the Kimi Code Console backend.

func NewClient

func NewClient(cfg *config.Config) (*Client, error)

NewClient creates a Client using the provided config, environment variables or JWT claims.

func (*Client) GetSubscription

func (c *Client) GetSubscription(ctx context.Context) (*GetSubscriptionResponse, error)

GetSubscription fetches subscription, balances and capabilities.

func (*Client) GetUsages

func (c *Client) GetUsages(ctx context.Context, scope string) (*GetUsagesResponse, error)

GetUsages fetches weekly usage and rate limits for the given scope.

type Constraint

type Constraint struct {
	Parallelism int `json:"parallelism"`
}

Constraint holds resource limits for a capability.

type GetSubscriptionResponse

type GetSubscriptionResponse struct {
	Subscription         Subscription `json:"subscription"`
	Balances             []Balance    `json:"balances"`
	Subscribed           bool         `json:"subscribed"`
	PurchaseSubscription Subscription `json:"purchaseSubscription"`
	Capabilities         []Capability `json:"capabilities"`
}

GetSubscriptionResponse is the response body for GetSubscription.

type GetUsagesRequest

type GetUsagesRequest struct {
	Scope []string `json:"scope"`
}

GetUsagesRequest is the request body for GetUsages.

type GetUsagesResponse

type GetUsagesResponse struct {
	Usages []Usage `json:"usages"`
}

GetUsagesResponse is the response body for GetUsages.

type Goods

type Goods struct {
	ID              string       `json:"id"`
	Title           string       `json:"title"`
	DurationDays    int          `json:"durationDays"`
	UseRegion       string       `json:"useRegion"`
	CreateTime      string       `json:"createTime"`
	UpdateTime      string       `json:"updateTime"`
	MembershipLevel string       `json:"membershipLevel"`
	Amounts         []Amount     `json:"amounts"`
	BillingCycle    BillingCycle `json:"billingCycle"`
}

Goods describes a subscription plan.

type LimitWindow

type LimitWindow struct {
	Duration int    `json:"duration"`
	TimeUnit string `json:"timeUnit"`
}

LimitWindow describes the duration of a rate limit window.

type Subscription

type Subscription struct {
	SubscriptionID   string `json:"subscriptionId"`
	Goods            Goods  `json:"goods"`
	SubscriptionTime string `json:"subscriptionTime"`
	CurrentStartTime string `json:"currentStartTime"`
	CurrentEndTime   string `json:"currentEndTime"`
	NextBillingTime  string `json:"nextBillingTime"`
	Status           string `json:"status"`
	PaymentChannel   string `json:"paymentChannel"`
	Type             string `json:"type"`
	Active           bool   `json:"active"`
}

Subscription contains current plan details.

type Usage

type Usage struct {
	Scope  string       `json:"scope"`
	Detail UsageDetail  `json:"detail"`
	Limits []UsageLimit `json:"limits"`
}

Usage represents usage for a single feature scope.

type UsageDetail

type UsageDetail struct {
	Limit     string `json:"limit"`
	Remaining string `json:"remaining"`
	ResetTime string `json:"resetTime"`
}

UsageDetail contains limit, remaining quota and reset time.

type UsageLimit

type UsageLimit struct {
	Window LimitWindow `json:"window"`
	Detail UsageDetail `json:"detail"`
}

UsageLimit represents a rate limit window and its detail.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL