Skip to content

OCR Prediction

Basic example showing how to create a client and run OCR prediction on an image URL.

This example assumes using Nanonets; is in scope and apiKey contains your Nanonets API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
using var client = new NanonetsClient(apiKey);

// Create a Nanonets client and predict using an OCR model.
// The model must be created and trained on the Nanonets web app first.
var modelId =
    Environment.GetEnvironmentVariable("NANONETS_MODEL_ID") is { Length: > 0 } modelValue
        ? modelValue
        : throw new AssertInconclusiveException("NANONETS_MODEL_ID environment variable is not found.");

var result = await client.OcrPredict.OcrPredictUrlAsync(
    modelId: modelId,
    urls: "https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg");