CreateChat creates a new chat.
(ctx context.Context, req CreateChatRequest)
| 2804 | |
| 2805 | // CreateChat creates a new chat. |
| 2806 | func (c *ExperimentalClient) CreateChat(ctx context.Context, req CreateChatRequest) (Chat, error) { |
| 2807 | res, err := c.Request(ctx, http.MethodPost, "/api/experimental/chats", req) |
| 2808 | if err != nil { |
| 2809 | return Chat{}, err |
| 2810 | } |
| 2811 | if res.StatusCode != http.StatusCreated { |
| 2812 | return Chat{}, readBodyAsChatUsageLimitError(res) |
| 2813 | } |
| 2814 | defer res.Body.Close() |
| 2815 | var chat Chat |
| 2816 | return chat, json.NewDecoder(res.Body).Decode(&chat) |
| 2817 | } |
| 2818 | |
| 2819 | // StreamChatOptions are optional parameters for StreamChat. |
| 2820 | type StreamChatOptions struct { |