Contextual AI Component APIs

State-of-the-art components to enhance every step of your RAG pipeline

column-image

CORE RAG BUILDING BLOCKS

Optimize your RAG pipeline end-to-end with powerful APIs for document understanding, reranking, generation, and evaluation

column-image

STATE-OF-THE-ART PERFORMANCE

Build more powerful agents with components that outperform competing solutions on industry-leading benchmarks

column-image

SIMPLE, FLEXIBLE INTEGRATION

Incorporate components into your existing RAG pipeline without needing to overhaul your entire architecture

Build better RAG agents

Powerful RAG components for when accuracy and performance matter

Parse

Our document understanding pipeline, capable of processing complex, multimodal content

(Coming Soon)

Rerank

The first instruction-following reranker, providing greater control over how retrievals are prioritized

Learn more

Generate

The most grounded language model in the world, engineered specifically to minimize hallucinations

Learn more

LMUnit

Our evaluation-optimized model for preference, direct scoring, and granular unit test evaluation

Learn more

Achieve even greater performance
with the Contextual AI Platform

 

Each component API achieves state-of-the-art performance. The Contextual AI Platform achieves even greater end-to-end performance by jointly optimizing the components as a single, unified system.

State-of-the-art Capabilities

PARSE

Extract complex multimodal content from any document

  • Convert unstructured documents into structured output optimized for your RAG pipeline
  • Easily process text, charts, tables, code, and other complex modalities
  • Enhance responses with precise bounding box attributions over the retrieved document

RERANK

Resolve knowledge conflicts with the only instruction-following reranker

  • Steer how your reranker prioritizes information with natural language instructions
  • Serve the most relevant content to your model’s context—with or without instructions
  • Drop into your existing RAG pipeline with just a few lines of code

GENERATE

Maximize accuracy with the world’s most grounded language model

  • Generate answers strongly grounded in your retrieved documents
  • Minimize hallucinations with response tags to delineate between facts and model commentary
  • Provide in-line attributions to source documents for end-users to verify responses

LMUnit

Evaluate LLM responses with fine-grained natural language unit tests

  • Assess responses for your defined criteria, like conciseness, technical precision, and more
  • Test for accuracy with out-of-the-box evaluation tests for equivalence and groundedness
  • Reduce your dependence on end-user testing and get to production faster

Simple APIs to improve your RAG pipelines

Component APIs
# Rank retrieved documents using instructions

import os
from contextual import ContextualAI

client = ContextualAI(api_key=os.environ.get("CONTEXTUAL_API_KEY"))

rerank_response = client.rerank.create(
    query = "your query",
    instruction = "your instructions",
    documents = ["your documents"],
    metadata = ["your metadata"],
    model = "ctxl-rerank-en-v1-instruct"
)

print(rerank_response.to_dict())
# Generate highly grounded responses

import os
from contextual import ContextualAI

client = ContextualAI(api_key=os.environ.get("CONTEXTUAL_API_KEY"))

generate_response = client.generate.create(
    model="v1",
    messages=[{
        "content": "content",
        "role": "user",
    }],
    knowledge=["your knowledge"],
    avoid_commentary=False
)

print(generate_response.response)
# Evaluate responses with user-defined unit tests

import os
from contextual import ContextualAI

client = ContextualAI(api_key=os.environ.get("CONTEXTUAL_API_KEY"))

response = client.lmunit.create(
    query="your query",
    response="your response",
    unit_test="your unit test"
)

print(response)
Milo Moerkerke
Co-founder at ClaimWise

“At ClaimWise, we work with complex patents and scientific articles. Meeting the quality expectations of our users has always been one of our main technical challenges. The Contextual AI reranker’s instruction-following capability is great; we have some nuanced requirements about how to prioritize different types of paragraphs for different fields of invention, and the reranker follows those instructions well.”

Additional Resources

Pricing

 

Understanding Contextual AI’s pricing model
Learn how our token-based pricing model for Component APIs makes it easy to keep costs in check as your workload scales

Learn more

Platform

 

Delivering superior accuracy and performance
Understand how the Contextual AI Platform jointly optimizes our state-of-the-art components to further improve end-to-end accuracy

Read more

Security

 

Protecting and safeguarding your enterprise
See how Contextual AI enforces robust security controls, stringent data protection, and comprehensive compliance measures

Learn more