Logo

Feature

What is a Feature?

Features are the building blocks of your product offering, they represent the various capabilities of your system. Practically speaking, they typically translate to line items on your pricing page, so we'll use this thinking going forward.

The feature set between plans can vary in terms of what features are available, what configurations are available for a given feature, and what usage limits are enforced. Let's see an example for a fictional AI startup:

FeaturePlan 1Plan 2
Feature 1: GPT Tokens10,000 /m1,000,000 /m
Feature 2: Available Modelsgpt-3gpt-3, gpt-4
Feature 3: SAML SSO Auth-Yes

You can see how, when modeling this, the table rows naturally translate to features, while the individual cells (plan specific configurations) translate to entitlements.

Using Features

Do it yourself!

Check out the Get Started guide to see how to create your first features using the OpenMeter SDK.

Features have a system generated Id and a user defined Key. Key should be an easy to understand string that can be used to reference the feature in your codebase, e.g. gpt_4_tokens. The entitlement access APIs can be used with feature key too, so you don't have to resolve the Ids before each query.

// Creating a feature via SDK
const feature = await openmeter.features.create({
  key: 'saml_sso',
  name: 'SAML SSO',
});

Features can be archived, after which no new entitlements can be created for them, but the existing entitlement are left intact. You can think of this as deprecating a feature, removing it from the pricing page, or migrating it to a new name (key). Feature key has to be unique among active (non archived) features, but archived features can have the same key as other archived or active ones.

// Archiving a feature via SDK
await openmeter.features.delete('saml_sso');
 
// Querying all features
const features = await openmeter.features.list({
  includeArchived: false,
});
// => [...], archived feature is not returned
 
// Trying to create a feature with the same key as an archived one
const feature = await openmeter.features.create({
  key: 'saml_sso',
  name: 'New SAML SSO',
});
// => Success
 
// Attempting to create an entitlement for the feature
const entitlement = await openmeter.subjects.createEntitlement('customer-1', {
  type: 'boolean',
  featureId: oldFeature.id,
});
// => Error: Feature not found

If you want to track usage for a feature, you can associate a meter with it. The associated meter will be used to track usage in metered entitlements of the feature, and it must have either SUM or COUNT as its aggregation type. You can also filter the usage tracked by the meter using the meterGroupByFilter property. This is useful if you want to share the same meter accross different features, but want to track and enforce usage separately based on some differentiating property. When doing this, the meter must have the same group by keys defined which you want to use for metering.

// Create feature GPT-4 Tokens
const meteredFeature = await openmeter.features.create({
  key: 'gpt_4_tokens',
  name: 'GTP-4 Tokens',
  meterSlug: 'tokens_total',
  meterGroupByFilters: {
    model: 'gpt-4',
  },
});
 
const invalid = await openmeter.features.create({
  key: 'openai_tokens',
  name: 'OpenAI Tokens',
  meterSlug: 'tokens_total',
  meterGroupByFilters: {
    vendor: 'openai',
  },
});
// => Error: Meter group by filters do not match the meter's group by keys
PropertyDescription
keyA unique lookup key to help access features in API or web.
nameA human-readable display name for the feature.
meterSlugOptional, Associated meter to measure subject usage.
meterGroupByFilterOptional, to filter for a subset of usage in the meter.
Read the docs

Check our API Docs for detailed descriptions of all feature properties.

Getting Started

Check out the Get Started guide to get started with OpenMeter Entitlements or use the Cloud UI:

Features Dashboard

Examples

Check out some examples of features:

GPT-4 Tokens

The feature GPT-4 Tokens is used to track the token usage and enforce limits.

PropertyValue
keygpt_4_tokens
nameGPT-4 Tokens
metertokens_total
meterGroupByFiltermodel=gpt-4

Available Models

The feature Available Models is used to determine what models are available for the subject.

PropertyValue
keygpt_models
nameAvailable GPT models
meter-
meterGroupByFilter-

SAML SSO

The feature SAML SSO enables SAML SSO for the subject.

PropertyValue
keysaml_sso
nameSAML SSO
meter-
meterGroupByFilter-