• Cheat sheets
  • Documentation
  • API reference
  • Product updates
  • Sign in
Kontent.ai Learn
  • Try Kontent.ai
  • Plan
  • Set up
  • Model
  • Develop
  • Create
Copyright © 2025 Kontent.ai. All rights reserved.
  • Web
  • Privacy policy
  • Cookies policy
  • Consent settings
  • Security
  • GDPR
  • Overview
  • Manage API keys
  • Hello World
  • Hello Web Spotlight
  • Try sample apps
  • Build apps
    • Generate models
    • Resolve rich text
    • Resolve linked content
  • Decide navigation and URLs
  • Environments
  • Get Developer Certification

Turn your content types into strongly typed models

Jan Cerman
13 minutes
Delivery API
Download PDF
  • TypeScript
  • .NET
  • Java
0% complete
Improve your development experience by using strongly typed models based on your Kontent.ai content types.

Life without strongly typed models

When getting content directly from the Delivery REST API, you receive content items as JSON objects. Your app then needs to parse the JSON to display your content. For example, to access the Headline element in a content item, you’d use a notation like this response.data.item.elements.headline.value.
In real-life scenarios, this approach might be cumbersome because it requires you to remember the JSON structure of your content items, and the codenames of your elements, types, languages, and other entities.   To make this easier, use a Delivery SDK (the JS version or the .NET version) to map the retrieved content items to their strongly typed models.

Build your app with strongly typed models

The video below, by Cameron Tape, our Senior Technical Support Engineer, shows how to set up a TypeScript-based web app using Next.js and install the JavaScript Delivery SDK and the model generator to get and display content from Kontent.ai.

Use strongly typed models

This practice has several advantages:
  • type safety during compile-time
  • convenience (IntelliSense remembers content type properties for you)
  • support of type-dependent functionalities
Each model corresponds to a content type in your Kontent.ai project.
A strongly typed model provides type-safe access to:
  • All elements defined within a specific content type
  • System fields such as type, workflow, language, and more
The following example is a strongly typed model of the Homepage content type.
  • C#

Generate models

Use the model generator to create strongly typed models from your Kontent.ai project by providing your environment ID.

Get strongly typed content

With your models defined and added to your application, you can use them when retrieving items from Kontent.ai.
Sign in with your Kontent.ai credentials or sign up for free to unlock the full lesson, track your progress, and access exclusive expert insights and tips!
Sign in
  • Shell
  • C#
We recommend that you generate the models using the .NET model generator.
// This code was generated by a kontent-generators-net tool 
// (see https://github.com/kontent-ai/model-generator-net).
// 
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 
// For further modifications of the class, create a separate file with the partial class.

using System;
using System.Collections.Generic;
using Kontent.Ai.Delivery.Abstractions;

namespace KontentAiModels
{
    public partial class Homepage
    {
        public const string Codename = "homepage";
        public const string BodyTextCodename = "body_text";
        public const string HeadlineCodename = "headline";
        public const string PictureCodename = "picture";

        public IRichTextContent BodyText { get; set; }
        public string Headline { get; set; }
        public IEnumerable<IAsset> Picture { get; set; }
        public IContentItemSystemAttributes System { get; set; }
    }
}
dotnet tool install -g Kontent.Ai.ModelGenerator
KontentModelGenerator --projectid 8d20758c-d74c-4f59-ae04-ee928c0816b7 --withtypeprovider true --structuredmodel true
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Delivery;
using KontentAiModels;

// Tip: Use DI to create Delivery client https://kontent.ai/learn/net-register-client
IDeliveryClient client = DeliveryClientBuilder
      .WithEnvironmentId("8d20758c-d74c-4f59-ae04-ee928c0816b7")
      .Build();

// Gets a content item by codename and maps it to the item's strongly typed model
IDeliveryItemResponse<Homepage> response = await client.GetItemAsync<Homepage>("hello_caas_world");

var homepage = response.Item;
// Use homepage
// Console.WriteLine(homepage.Headline);
  • Life without strongly typed models
  • Build your app with strongly typed models
  • Use strongly typed models
  • Generate models
  • Get strongly typed content