Skip to content

Create a Model API Key

client.Inference.APIKeys.New(ctx, body) (*InferenceAPIKeyNewResponse, error)
post/v2/gen-ai/models/api_keys

To create a model API key, send a POST request to /v2/gen-ai/models/api_keys.

ParametersExpand Collapse
body InferenceAPIKeyNewParams
Name param.Field[string]optional

A human friendly name to identify the key

ReturnsExpand Collapse
type InferenceAPIKeyNewResponse struct{…}
APIKeyInfo APIModelAPIKeyInfooptional

Model API Key Info

CreatedAt Timeoptional

Creation date

formatdate-time
CreatedBy stringoptional

Created by

formatuint64
DeletedAt Timeoptional

Deleted date

formatdate-time
Name stringoptional

Name

SecretKey stringoptional
Uuid stringoptional

Uuid

Create a Model API Key
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/-go"
  "github.com/stainless-sdks/-go/option"
)

func main() {
  client := gradient.NewClient(
    option.WithAccessToken("My Access Token"),
  )
  apiKey, err := client.Inference.APIKeys.New(context.TODO(), gradient.InferenceAPIKeyNewParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", apiKey.APIKeyInfo)
}
{
  "api_key_info": {
    "created_at": "2023-01-01T00:00:00Z",
    "created_by": "12345",
    "deleted_at": "2023-01-01T00:00:00Z",
    "name": "example name",
    "secret_key": "example string",
    "uuid": "123e4567-e89b-12d3-a456-426614174000"
  }
}
Returns Examples
{
  "api_key_info": {
    "created_at": "2023-01-01T00:00:00Z",
    "created_by": "12345",
    "deleted_at": "2023-01-01T00:00:00Z",
    "name": "example name",
    "secret_key": "example string",
    "uuid": "123e4567-e89b-12d3-a456-426614174000"
  }
}