Learn how to use your OpenAPI client to call your functions in Boundary Functions.

This page assumes you’ve already deployed your BAML code to Boundary Functions. If you haven’t done that yet, check out the guide for getting started.

This page assumes you’re using an OpenAPI-generated BAML client. If you haven’t done that yet, check out the OpenAPI quickstart.

Create an API key

You can create API keys in the Boundary Dashboard by going to the left sidebar and clicking on the key icon.

Boundary Functions API keys

Once you’ve created a new key, update your application code to use it as BOUNDARY_API_KEY.

Update your application code

You also need to update your application code to use BOUNDARY_ENDPOINT and BOUNDARY_API_KEY, if set, when constructing the OpenAPI client.

1import (
2 "os"
3 baml "my-golang-app/baml_client"
4)
5
6func main() {
7 cfg := baml.NewConfiguration()
8 if boundaryEndpoint := os.Getenv("BOUNDARY_ENDPOINT"); boundaryEndpoint != "" {
9 cfg.BasePath = boundaryEndpoint
10 }
11 if boundaryApiKey := os.Getenv("BOUNDARY_API_KEY"); boundaryApiKey != "" {
12 cfg.DefaultHeader["Authorization"] = "Bearer " + boundaryApiKey
13 }
14 b := baml.NewAPIClient(cfg).DefaultAPI
15 // Use `b` to make API calls
16}

Set your environment variables

You can now set the following environment variables in your application:

$BOUNDARY_API_KEY=...
>BOUNDARY_ENDPOINT=https://api2.boundaryml.com/v3/functions/prod/

Call your functions

You should now be able to call your deployed BAML functions using your OpenAPI client!