xonecas.io
6312
Ga

go-opencode-ai-zen-sdk / files

go-opencode-ai-zen-sdk / models.go

619 bytes
1package zen
2
3import (
4	"context"
5	"encoding/json"
6)
7
8type ModelsResponse struct {
9	Data []Model         `json:"data"`
10	Raw  json.RawMessage `json:"-"`
11}
12
13type Model struct {
14	ID      string `json:"id"`
15	Object  string `json:"object"`
16	OwnedBy string `json:"owned_by"`
17}
18
19func (c *Client) ListModels(ctx context.Context) (*ModelsResponse, error) {
20	data, _, err := c.doRequest(ctx, "GET", "/models", nil, EndpointModels, true)
21	if err != nil {
22		return nil, err
23	}
24
25	var resp ModelsResponse
26	if err := json.Unmarshal(data, &resp); err != nil {
27		return nil, err
28	}
29	resp.Raw = json.RawMessage(data)
30	return &resp, nil
31}