# OpenRouter Extractions API: Verify Text Spans with Emoji and Accented Text

> Check OpenRouter extraction spans in JavaScript without corrupting offsets, and keep unsupported fields out of downstream records.

Canonical article: https://modelrovia.com/guides/openrouter-extractions-unicode-spans/
Author: Modelrovia Editorial
Published: 2026-11-17
Updated: 2026-11-17

## Key takeaway

Use Unicode code points to verify each literal text span against the exact input, and preserve absent fields as null.

OpenRouter’s Extractions API measures text spans in **Unicode code points**. JavaScript indexes ordinary strings in UTF-16 code units. As soon as an emoji precedes a field, passing the API offsets straight to `String.slice()` can highlight the wrong text. Convert the exact input to code points before slicing. [OpenRouter Extractions announcement](https://openrouter.ai/blog/announcements/extractions-api/)

## Reproduce the offset difference

OpenRouter lists its November 10 release as alpha. For a small text trial, choose the documented `cloudflare/clairic` model. Send a literal text field named `reference`, and ask for a separate `purchase_order` field even though it is absent from the input. Save the exact input and the response together. Clairic can also echo the span's source text when requested through its provider option.

Run the following independently of the API. The offsets are authored fixtures.

~~~js
const state = "📦 Réf: A-017";

function textAtSpan(state, span) {
  const points = Array.from(state);
  if (!Array.isArray(span) || span.length !== 2) return null;
  const [start, end] = span;
  if (!Number.isInteger(start) || !Number.isInteger(end) ||
      start < 0 || start >= end || end > points.length) return null;
  return points.slice(start, end).join("");
}

const span = [7, 12];
console.log(state.slice(...span));     // " A-01"
console.log(textAtSpan(state, span)); // "A-017"
console.log(textAtSpan(state, [7, 20])); // null
~~~

Store the input exactly as submitted. Even normalizing composed letters or changing line endings after submission can shift locations. When a result is supposed to copy a literal value, compare the extracted slice with the returned string and send mismatches for review.

## Give missing evidence its own outcome

- A `null` value means the response has no accepted value for that field. Keep it null even if a `guess` is present.
- A valid span with matching text shows where a literal string was found. Check that the passage labels it as the right kind of reference before accepting it.
- An absent span needs a different review path. OpenRouter documents cases such as ScaleDown’s PDF responses that do not include offsets. Computed values such as a payment deadline also require a different check from literal text matching.

If the response indicates truncation, check which part of the document the provider saw before interpreting a missing value. A field at the end of a long document may require another bounded extraction.

**Verification on November 17.** We ran the JavaScript on the sample above, including its invalid-range case. The fixture does not represent an actual API response.

## Sources & references

- [OpenRouter: Extractions API, field metadata and span indexing](https://openrouter.ai/blog/announcements/extractions-api/)

[Editorial standards](https://modelrovia.com/methodology/)
