---
title: Customize the agent for AI monitoring
source: https://docs.newrelic.com/docs/ai-monitoring/customize-agent-ai-monitoring
---

Once you [install AI monitoring](/install/ai-monitoring), you can configure the default behavior of the agent or update your app to collect different kinds of data.

## Configure the agent [#configure-agents]

Update default agent behavior for AI monitoring at these agent configuration docs:

**Go configurations**

-   [`ai_monitoring.enabled`](https://docs.newrelic.com/docs/apm/agents/go-agent/configuration/go-agent-configuration/#ai-monitoring-enabled)
-   [`ai_monitoring.streaming.enabled`](https://docs.newrelic.com/docs/apm/agents/go-agent/configuration/go-agent-configuration/#ai-monitoring-streaming)
-   [`ai_monitoring.record_content.enabled`](https://docs.newrelic.com/docs/apm/agents/go-agent/configuration/go-agent-configuration/#ai-monitoring-record-content)
-   [`ConfigCustomInsightsEventsMaxSamplesStored`](https://docs.newrelic.com/docs/apm/agents/go-agent/configuration/go-agent-configuration/#env-var-table)

**.NET configurations**

-   [`ai_monitoring.enabled`](https://docs.newrelic.com/docs/apm/agents/net-agent/configuration/net-agent-configuration/#ai_monitoring)
-   [`ai_monitoring.record_content.enabled`](https://docs.newrelic.com/docs/apm/agents/net-agent/configuration/net-agent-configuration/#aiMonitoring_recordContent)
-   [`customEvents.maximumSamplesStored`](https://docs.newrelic.com/docs/apm/agents/net-agent/configuration/net-agent-configuration/#customevents-maximumSamplesStored)
-   [`spanEvents.maximumSamplesStored`](https://docs.newrelic.com/docs/apm/agents/net-agent/configuration/net-agent-configuration/#span-max-samples-stored)

**Java configurations**

-   [`ai_monitoring.enabled`](https://docs.newrelic.com/docs/apm/agents/java-agent/configuration/java-agent-configuration-config-file/#ai-monitoring-enabled)
-   [`ai_monitoring.record_content.enabled`](https://docs.newrelic.com/docs/apm/agents/java-agent/configuration/java-agent-configuration-config-file/#ai-monitoring-record-content)
-   [`custom_insights_events.max_samples_stored`](https://docs.newrelic.com/docs/apm/agents/java-agent/configuration/java-agent-configuration-config-file/#cie-max_samples_stored)
-   [`span_events.max_samples_stored`](https://docs.newrelic.com/docs/apm/agents/java-agent/configuration/java-agent-configuration-config-file/#cfg-span-events-max-samples-stored)

**Node.js configurations**

-   [`ai_monitoring.enabled`](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration/#ai-monitoring-enabled)
-   [`ai_monitoring.streaming.enabled`](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration/#ai-monitoring-streaming)
-   [`ai_monitoring.record_content.enabled`](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration/#ai-monitoring-record-content)
-   [`custom_insights_events.max_samples_stored`](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration/#custom_events_max_samples_stored)
-   [`span_events.max_samples_stored`](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration/#span-events-max-samples-stored)

**Python configurations**

-   [`ai_monitoring.enabled`](https://docs.newrelic.com/docs/apm/agents/python-agent/configuration/python-agent-configuration/#ai-monitoring-enabled)
-   [`ai_monitoring.streaming.enabled`](https://docs.newrelic.com/docs/apm/agents/python-agent/configuration/python-agent-configuration/#ai-monitoring-streaming)
-   [`ai_monitoring.record_content.enabled`](https://docs.newrelic.com/docs/apm/agents/python-agent/configuration/python-agent-configuration/#ai-monitoring-record-content)
-   [`span_events.max_samples_stored`](https://docs.newrelic.com/docs/apm/agents/python-agent/configuration/python-agent-configuration/#cfg-tt-max-samples-stored)
-   [`event_harvest_config.harvest_limits.ml_event_data`](https://docs.newrelic.com/docs/apm/agents/python-agent/configuration/python-agent-configuration/#harvest-limits-ml-event-data)

**Ruby configurations**

-   [`ai_monitoring.enabled`](https://docs.newrelic.com/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration/#ai-monitoring-enabled)
-   [`instrumentation.ruby_openai`](https://docs.newrelic.com/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration/#ruby-openai)
-   [`ai_monitoring.record_content.enabled`](https://docs.newrelic.com/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration/#ai-monitoring-record-content)
-   [`span_events.max_samples_stored`](https://docs.newrelic.com/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration/#custom_insights_events-max_samples_stored)
-   [`custom_insights_events.max_samples_stored`](https://docs.newrelic.com/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration/#span_events-max_samples_stored)

## Token count method [#enable-token]

If you haven't disabled `ai_monitoring.record_content.enabled`, you don't need to implement the token count callback API.

Disabling `ai_monitoring.record_content.enabled` stops the agent from sending AI content to New Relic, but it also prevents the agent from forwarding token counts for interactions with your app. You can implement a callback in your app code to determine the token counts locally, then have that information forwarded to New Relic.

Refer to the docs below for examples to set up counting tokens locally:

**Go token count method**

Refer to the Go API docs for [`SetLLMTokenCountCallback`](https://pkg.go.dev/github.com/newrelic/go-agent/v3/newrelic#Application.SetLLMTokenCountCallback)

**.NET token count method**

Refer to our API docs for [`SetLlmTokenCountingCallback`](https://docs.newrelic.com/docs/apm/agents/net-agent/net-agent-api/setllmtokencountingcallback-net-agent-api)

**Java token count method**

Refer to our API docs for [`setLlmTokenCountCallback`](https://newrelic.github.io/java-agent-api/javadoc/com/newrelic/api/agent/AiMonitoring.html#setLlmTokenCountCallback)

**Node.js token count method**

Refer to our API docs for:

-   [`setLlmTokenCountCallback`](https://newrelic.github.io/node-newrelic/API.html#setLlmTokenCountCallback)
-   [`getTraceMetadata`](https://newrelic.github.io/node-newrelic/API.html#getTraceMetadata)

**Python token count method**

Refer to our API docs for [`set_llm_token_count_callback`](https://docs.newrelic.com/docs/apm/agents/python-agent/python-agent-api/setllmtokencountcallback-python-agent-api).

**Ruby token count method**

Refer to our API docs for [`NewRelic::Agent.set_llm_token_count_callback`](https://docs.newrelic.com/docs/apm/agents/ruby-agent/api-guides/ruby-ai-monitoring-apis).

## User feedback methods [#enable-feedback]

If end users can leave feedback on an AI response, you can forward this data into the AI monitoring response table. To do this, you'll update your app code to correlate trace IDs from AI event data using callback methods.

There are two methods you need to implement to forward this kind of information:

**Go feedback methods**

Refer to the Go API docs for:

-   [`GetTraceMetadata`](https://pkg.go.dev/github.com/newrelic/go-agent/v3/newrelic#Application.getTraceMetadata)
-   [`RecordLLMFeedbackEvent`](https://pkg.go.dev/github.com/newrelic/go-agent/v3/newrelic#Application.RecordLLMFeedbackEvent)

**Java feedback methods**

Refer to the Java API docs for:

-   [`TraceMetadata.getTraceId()`](https://newrelic.github.io/java-agent-api/javadoc/com/newrelic/api/agent/TraceMetadata.html#getTraceId)
-   [`recordLlmFeedbackEvent`](https://newrelic.github.io/java-agent-api/javadoc/com/newrelic/api/agent/AiMonitoring.html#recordLlmFeedbackEvent)

**Node.js feedback methods**

Refer to our API docs for [`recordLlmFeedbackEvent`](https://newrelic.github.io/node-newrelic/API.html#recordLlmFeedbackEvent)

**Python feedback methods**

Refer to our API docs for:

-   [`newrelic.agent.current_trace_id()`](https://docs.newrelic.com/docs/apm/agents/python-agent/python-agent-api/currenttraceid-python-agent)
-   [`record_llm_feedback_event`](https://docs.newrelic.com/docs/apm/agents/python-agent/python-agent-api/recordllmfeedbackevent-python-agent-api)

**Ruby feedback methods**

Refer to our API docs for [`NewRelic::Agent.record_llm_feedback_event`](https://docs.newrelic.com/docs/apm/agents/ruby-agent/api-guides/ruby-ai-monitoring-apis/#user-feedback)
