# getScorer()
[EN] Source: https://mastra.ai/reference/core/getScorer

The `getScorer()` method retrieves a specific scorer that was registered with the Mastra instance using its registration key. This method provides type-safe access to scorers and throws an error if the requested scorer is not found.

## Usage Example

```typescript
import { mastra } from "./mastra";

// Get a specific scorer by key
const relevancyScorer = mastra.getScorer("relevancyScorer");

const weatherAgent = mastra.getAgent("weatherAgent");

// Use the scorer to evaluate an AI output
await weatherAgent.generate("What is the weather in Rome", {
  scorers: {
    answerRelevancy: {
      scorer: relevancyScorer,
    },
  },
});
```

## Parameters

<PropertiesTable
  content={[
    {
      name: "key",
      type: "string",
      description:
        "The registration key of the scorer to retrieve. This should match a key used when registering scorers in the Mastra constructor.",
      isOptional: false,
    },
  ]}
/>

## Returns

<PropertiesTable
  content={[
    {
      name: "scorer",
      type: "MastraScorer",
      description:
        "The MastraScorer instance associated with the provided key.",
    },
  ]}
/>

## Error Handling

This method throws a `MastraError` if:

- The scorer with the specified key is not found
- No scorers are registered with the Mastra instance

```typescript
try {
  const scorer = mastra.getScorer("nonExistentScorer");
} catch (error) {
  if (error.id === "MASTRA_GET_SCORER_NOT_FOUND") {
    console.log("Scorer not found, using default evaluation");
  }
}
```

## Related

- [getScorers()](/reference/core/getScorers) - Get all registered scorers
- [getScorerByName()](/reference/core/getScorerByName) - Get a scorer by its name property
- [Custom Scorers](/docs/scorers/custom-scorers) - Learn how to create custom scorers


---
title: "Reference: getScorerByName() | Core"
description: "Documentation for the `getScorerByName()` method in Mastra, which retrieves a scorer by its name property rather than registration key."
---