Skip to main content
POST
https://api.classer.ai
/
v1
/
match
Match
curl --request POST \
  --url https://api.classer.ai/v1/match \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "source": "<string>",
  "query": "<string>",
  "model": "<string>"
}
'
{
  "score": 0.9512,
  "latency_ms": 138,
  "usage": {
    "prompt_tokens": 45,
    "completion_tokens": 1,
    "total_tokens": 46
  }
}

Request

source
string
required
The source document text
query
string
required
The query to match against
model
string
Model override (optional)

Response

score
number
Relevance score between 0 and 1
latency_ms
number
Processing time in milliseconds
usage
object
Token usage information

Use Cases

  • RAG Retrieval — Re-rank retrieved documents by relevance
  • Search — Score search results
  • Deduplication — Find similar documents
  • Q&A — Check if a document answers a question

Examples

Basic matching

import classer

result = classer.match(
    source="Our return policy allows refunds within 30 days of purchase.",
    query="Can I get a refund?"
)

print(result.score)  # 0.95

RAG re-ranking

Use match to re-rank documents after initial retrieval:
Python
import classer

# Documents retrieved from vector search
documents = [
    "Our return policy allows refunds within 30 days.",
    "Contact support at [email protected]",
    "Shipping takes 3-5 business days.",
]

query = "How do I get my money back?"

# Score each document
scored = []
for doc in documents:
    result = classer.match(source=doc, query=query)
    scored.append((doc, result.score))

# Sort by relevance
scored.sort(key=lambda x: x[1], reverse=True)

# Top result
print(scored[0][0])  # "Our return policy allows refunds within 30 days."

Low relevance example

result = classer.match(
    source="The weather in Paris is sunny today.",
    query="How do I reset my password?"
)

print(result.score)  # 0.05
{
  "score": 0.9512,
  "latency_ms": 138,
  "usage": {
    "prompt_tokens": 45,
    "completion_tokens": 1,
    "total_tokens": 46
  }
}