Install the SDK and capture a generation
This milestone happens on your machine, in the shell from Milestone 4. Install the SDK, copy the capture sample from your language page, and change only how the client is created so it reads those variables.
Run the install command for your language in the shell from Milestone 4.
In the following table, click the link for the language you are using and locate the code sample.
Copy the code sample into a file you can run.
The Python, TypeScript and JavaScript, and Go samples run as copied. The Java sample is a fragment, so wrap it in a class with a
mainmethod and add imports for thecom.grafana.agento11ytypes it uses. The .NET sample uses anopenAIClientandinputItemsit doesn’t define, so create an OpenAI client with your provider key and a list of input items before theOpenAIRecorder.CreateResponseAsynccall.Change how the client is created so it reads the variables from Milestone 4.
Find the lines that create the client. They include the endpoint. Replace them with the one line for your language in the following table, which is also under Use environment variables instead on the same page. Leave every other line as it is, including the shutdown call.
For example, in Python, replace:
client = Client( ClientConfig( generation_export_endpoint="{AGENTO11Y_ENDPOINT}", ) )with:
client = Client()The import line and the rest of the sample stay as they are.
ClientConfigin the import is unused after this change, and leaving it there is fine.Run the file from the shell where you set the variables.
The Python, TypeScript and JavaScript, Go, and Java samples don’t call an LLM provider, so no provider key is needed. Each records one generation: conversation
conv-1, modelopenai/gpt-4o, and the assistant messageHello.The .NET sample calls the OpenAI provider helper, so run it with your provider key.
The SDK for your language is installed, and you have captured a generation.