@@ -53,11 +53,13 @@ import (
5353
5454func main () {
5555 client := llamastackclient.NewClient ()
56- healthInfo , err := client.Inspect .Health (context.TODO ())
56+ model , err := client.Models .Register (context.TODO (), llamastackclient.ModelRegisterParams {
57+ ModelID: " model_id" ,
58+ })
5759 if err != nil {
5860 panic (err.Error ())
5961 }
60- fmt.Printf (" %+v \n " , healthInfo. Status )
62+ fmt.Printf (" %+v \n " , model. Identifier )
6163}
6264
6365```
@@ -263,7 +265,7 @@ client := llamastackclient.NewClient(
263265 option.WithHeader (" X-Some-Header" , " custom_header_info" ),
264266)
265267
266- client.Inspect . Health (context.TODO (), ...,
268+ client.Chat . Completions . New (context.TODO (), ...,
267269 // Override the header
268270 option.WithHeader (" X-Some-Header" , " some_other_custom_header_info" ),
269271 // Add an undocumented field to the request body, using sjson syntax
@@ -294,14 +296,23 @@ When the API returns a non-success status code, we return an error with type
294296To handle errors, we recommend that you use the ` errors.As ` pattern:
295297
296298``` go
297- _ , err := client.Inspect .Health (context.TODO ())
299+ _ , err := client.Chat .Completions .New (context.TODO (), llamastackclient.ChatCompletionNewParams {
300+ Messages : []llamastackclient.ChatCompletionNewParamsMessageUnion {{
301+ OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser {
302+ Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion {
303+ OfString: llamastackclient.String (" string" ),
304+ },
305+ },
306+ }},
307+ Model : " model" ,
308+ })
298309if err != nil {
299310 var apierr *llamastackclient.Error
300311 if errors.As (err, &apierr) {
301312 println (string (apierr.DumpRequest (true ))) // Prints the serialized HTTP request
302313 println (string (apierr.DumpResponse (true ))) // Prints the serialized HTTP response
303314 }
304- panic (err.Error ()) // GET "/v1/health ": 400 Bad Request { ... }
315+ panic (err.Error ()) // GET "/v1/chat/completions ": 400 Bad Request { ... }
305316}
306317```
307318
@@ -319,8 +330,18 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`.
319330// This sets the timeout for the request, including all the retries.
320331ctx , cancel := context.WithTimeout (context.Background (), 5 *time.Minute )
321332defer cancel ()
322- client.Inspect . Health (
333+ client.Chat . Completions . New (
323334 ctx,
335+ llamastackclient.ChatCompletionNewParams {
336+ Messages : []llamastackclient.ChatCompletionNewParamsMessageUnion {{
337+ OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser {
338+ Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion {
339+ OfString: llamastackclient.String (" string" ),
340+ },
341+ },
342+ }},
343+ Model : " model" ,
344+ },
324345 // This sets the per-retry timeout
325346 option.WithRequestTimeout (20 *time.Second ),
326347)
@@ -375,7 +396,20 @@ client := llamastackclient.NewClient(
375396)
376397
377398// Override per-request:
378- client.Inspect .Health (context.TODO (), option.WithMaxRetries (5 ))
399+ client.Chat .Completions .New (
400+ context.TODO (),
401+ llamastackclient.ChatCompletionNewParams {
402+ Messages : []llamastackclient.ChatCompletionNewParamsMessageUnion {{
403+ OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser {
404+ Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion {
405+ OfString: llamastackclient.String (" string" ),
406+ },
407+ },
408+ }},
409+ Model : " model" ,
410+ },
411+ option.WithMaxRetries (5 ),
412+ )
379413```
380414
381415### Accessing raw response data (e.g. response headers)
@@ -386,11 +420,24 @@ you need to examine response headers, status codes, or other details.
386420``` go
387421// Create a variable to store the HTTP response
388422var response *http.Response
389- healthInfo , err := client.Inspect .Health (context.TODO (), option.WithResponseInto (&response))
423+ completion , err := client.Chat .Completions .New (
424+ context.TODO (),
425+ llamastackclient.ChatCompletionNewParams {
426+ Messages : []llamastackclient.ChatCompletionNewParamsMessageUnion {{
427+ OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser {
428+ Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion {
429+ OfString: llamastackclient.String (" string" ),
430+ },
431+ },
432+ }},
433+ Model : " model" ,
434+ },
435+ option.WithResponseInto (&response),
436+ )
390437if err != nil {
391438 // handle error
392439}
393- fmt.Printf (" %+v \n " , healthInfo )
440+ fmt.Printf (" %+v \n " , completion )
394441
395442fmt.Printf (" Status Code: %d \n " , response.StatusCode )
396443fmt.Printf (" Headers: %+#v \n " , response.Header )
0 commit comments