Users Pricing

blog

home / developersection / blogs / build a content analysis api in .net using ollama for automated seo metadata generation
Build a Content Analysis API in .NET Using Ollama for Automated SEO Metadata Generation

Build a Content Analysis API in .NET Using Ollama for Automated SEO Metadata Generation

Ravi Vishwakarma 35 11 Jun 2026 Updated 11 Jun 2026

Search Engine Optimization (SEO) is a critical factor in improving website visibility, search rankings, and user engagement. As content volume increases, manually generating SEO metadata such as tags, categories, keywords, and internal linking opportunities becomes inefficient.

By integrating Ollama with a .NET Web API, developers can automate content analysis and generate SEO metadata using locally hosted Large Language Models (LLMs). This approach offers improved privacy, lower operational costs, and complete control over content processing.

In this article, we will build a Content Analysis API using ASP.NET Core and Ollama that automatically generates:

  • SEO Tags
  • Content Categories
  • Focus Keywords
  • Internal Link Keywords
  • Meta Title Suggestions
  • Meta Description Suggestions
  • Content Summary

Why Use Ollama with .NET?

Ollama allows developers to run powerful AI models locally without relying on external AI services.

Benefits include:

  • Data privacy for unpublished content
  • Reduced API costs
  • Faster local processing
  • Easy integration with .NET applications
  • Support for Llama, Gemma, Mistral, DeepSeek, and other models

This makes Ollama an ideal solution for content management systems, blogging platforms, and SEO automation tools.

Solution Architecture

The overall workflow is straightforward:

Article Content
      |
      V
ASP.NET Core API
      |
      V
    Ollama
      |
      V
SEO Metadata JSON
      |
      +--> Category
      +--> Tags
      +--> Keywords
      +--> Link Keywords
      +--> Meta Title
      +--> Meta Description
      +--> Summary

Prerequisites

Before starting, install Ollama:

curl -fsSL https://ollama.com/install.sh | sh

Pull a model:

ollama pull llama3

Run the model:

ollama run llama3

By default, Ollama exposes an API at:

http://localhost:11434

Create ASP.NET Core Web API

Create a new project:

dotnet new webapi -n ContentAnalysisApi
cd ContentAnalysisApi

Create SEO Metadata Models

Create a folder named Models.

SeoMetadataResponse.cs

// Namespace declaration
namespace ContentAnalysisApi.Models
{
    // SEO response model
    public class SeoMetadataResponse
    {
        // Primary category
        public string Category { get; set; }

        // SEO tags
        public List<string> Tags { get; set; }

        // Focus keywords
        public List<string> Keywords { get; set; }

        // Internal linking keywords
        public List<string> LinkKeywords { get; set; }

        // Meta title
        public string MetaTitle { get; set; }

        // Meta description
        public string MetaDescription { get; set; }

        // Content summary
        public string Summary { get; set; }
    }
}

ContentRequest.cs

namespace ContentAnalysisApi.Models
{
    // Incoming content request
    public class ContentRequest
    {
        // Article content
        public string Content { get; set; }
    }
}

Create Ollama Request Models

OllamaRequest.cs

namespace ContentAnalysisApi.Models
{
    // Request sent to Ollama
    public class OllamaRequest
    {
        // AI model name
        public string Model { get; set; }

        // Prompt text
        public string Prompt { get; set; }

        // Disable streaming response
        public bool Stream { get; set; }
    }
}

OllamaResponse.cs

namespace ContentAnalysisApi.Models
{
    // Response returned by Ollama
    public class OllamaResponse
    {
        // Generated content
        public string Response { get; set; }
    }
}

Create Content Analysis Service

Create a folder named Services.

ContentAnalysisService.cs

using System.Text;
using System.Text.Json;
using ContentAnalysisApi.Models;

namespace ContentAnalysisApi.Services
{
    // Service responsible for communication with Ollama
    public class ContentAnalysisService
    {
        // HttpClient instance
        private readonly HttpClient _httpClient;

        // Constructor injection
        public ContentAnalysisService(HttpClient httpClient)
        {
            _httpClient = httpClient;
        }

        // Analyze content
        public async Task<string> AnalyzeContentAsync(string content)
        {
            // SEO prompt
            var prompt = $@"
Analyze the article and return ONLY valid JSON.

{{
    ""category"": """",
    ""tags"": [],
    ""keywords"": [],
    ""linkKeywords"": [],
    ""metaTitle"": """",
    ""metaDescription"": """",
    ""summary"": """"
}}

Rules:
- Generate SEO category.
- Generate tags.
- Generate keywords.
- Generate internal link keywords.
- Generate SEO meta title.
- Generate SEO meta description.
- Generate summary.

Article:
{content}
";

            // Create request payload
            var request = new OllamaRequest
            {
                Model = "llama3",
                Prompt = prompt,
                Stream = false
            };

            // Serialize request
            var json = JsonSerializer.Serialize(request);

            // Create HTTP content
            var httpContent = new StringContent(
                json,
                Encoding.UTF8,
                "application/json");

            // Send request to Ollama
            var response = await _httpClient.PostAsync(
                "http://localhost:11434/api/generate",
                httpContent);

            // Ensure success status
            response.EnsureSuccessStatusCode();

            // Read response body
            var responseBody =
                await response.Content.ReadAsStringAsync();

            // Parse Ollama response
            var ollamaResponse =
                JsonSerializer.Deserialize<OllamaResponse>(
                    responseBody);

            // Return generated JSON string
            return ollamaResponse?.Response;
        }
    }
}

Register Service

Update Program.cs.

using ContentAnalysisApi.Services;

// Create builder
var builder = WebApplication.CreateBuilder(args);

// Register controllers
builder.Services.AddControllers();

// Register HttpClient
builder.Services.AddHttpClient();

// Register service
builder.Services.AddScoped<ContentAnalysisService>();

// Swagger
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Enable swagger
app.UseSwagger();
app.UseSwaggerUI();

app.MapControllers();

app.Run();

Create API Controller

ContentAnalysisController.cs

using Microsoft.AspNetCore.Mvc;
using ContentAnalysisApi.Models;
using ContentAnalysisApi.Services;

namespace ContentAnalysisApi.Controllers
{
    [ApiController]
    [Route("api/content")]
    public class ContentAnalysisController : ControllerBase
    {
        private readonly ContentAnalysisService _service;

        // Constructor
        public ContentAnalysisController(
            ContentAnalysisService service)
        {
            _service = service;
        }

        // POST api/content/analyze
        [HttpPost("analyze")]
        public async Task<IActionResult> Analyze(
            [FromBody] ContentRequest request)
        {
            // Validate content
            if (string.IsNullOrWhiteSpace(request.Content))
            {
                return BadRequest("Content is required.");
            }

            // Analyze content
            var result =
                await _service.AnalyzeContentAsync(
                    request.Content);

            // Return response
            return Ok(result);
        }
    }
}

Example API Request

POST /api/content/analyze

Content-Type: application/json

{
  "content": "Artificial Intelligence is transforming SEO and digital marketing..."
}

Example Response

{
  "category": "Artificial Intelligence",
  "tags": [
    "AI",
    "SEO",
    "Content Marketing",
    "Digital Marketing"
  ],
  "keywords": [
    "AI SEO",
    "SEO automation",
    "content analysis"
  ],
  "linkKeywords": [
    "technical SEO",
    "keyword research",
    "AI tools"
  ],
  "metaTitle": "How AI is Transforming SEO in 2025",
  "metaDescription": "Discover how AI-powered tools are revolutionizing SEO and content optimization.",
  "summary": "An overview of AI-driven SEO automation and content optimization techniques."
}

Automatic Internal Link Injection

The linkKeywords field can be used to automatically connect related articles within your CMS.

Example:

Link Keyword Related Article
Technical SEO Technical SEO Best Practices
Keyword Research Advanced Keyword Research Guide
AI Tools Best AI Tools for Content Marketing

For technology websites, these keywords can be matched against existing content from MindStick Technology Articles, relevant discussions on MindStick Answers, or opinion-based content from YourViews by MindStick to strengthen internal linking and improve crawlability.

Production Improvements

For enterprise-grade implementations:

Structured JSON Output

Use Ollama's JSON mode:

{
  "format": "json"
}

Background Processing

Implement:

Caching

Store generated metadata in:

Additional SEO Features

Generate:

  • FAQ Schema
  • Open Graph Tags
  • Twitter Cards
  • Canonical URLs
  • Article Schema Markup
  • Related Content Recommendations

Conclusion

Combining ASP.NET Core and Ollama enables developers to create a powerful AI-driven content analysis platform capable of generating categories, tags, keywords, summaries, meta titles, meta descriptions, and internal linking opportunities automatically. This reduces manual SEO effort, improves content discoverability, and creates a scalable workflow for modern content management systems while maintaining complete control over data and AI infrastructure.


Ravi Vishwakarma

IT-Hardware & Networking

Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.