OpenAI-compatible chat completions (streaming search)

OpenAI-compatible chat completions endpoint that performs streaming search. This endpoint accepts the standard OpenAI chat completions format and returns search results in a streaming format.

The endpoint extracts the query from the last user message in the messages array and performs a search. All search parameters are passed via the extra_body field.

Important: This endpoint always returns a streaming response (SSE format), even when stream=False is specified. You should always use stream=True and process the response as a stream.

The response format follows OpenAI's streaming chat completions format, making it compatible with OpenAI client libraries.

Example:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.pearch.ai/",
    api_key="your-api-key"
)

stream = client.chat.completions.create(
    model="pearch",
    stream=True,
    messages=[{"role": "user", "content": "software engineers at Google with 10 years of experience"}],
    extra_body={
        "limit": 5,
        "type": "fast",
        "stream_profiles": "batch",
        "final_result": True
    }
)

for chunk in stream:
    if chunk.choices and len(chunk.choices) > 0:
        delta = chunk.choices[0].delta
        if delta and delta.content:
            print(delta.content, end="", flush=True)
        if chunk.choices[0].finish_reason is not None:
            print(f"\nFinished: {chunk.choices[0].finish_reason}")

Available Parameters in extra_body:

  • limit: Maximum number of results (1-1000, default: 10)
  • type: Search type - "fast" (1 credit/candidate) or "pro" (5 credits/candidate)
  • stream_profiles: Control profile streaming - "none", "full", or "batch"
  • profiles_batch_size: Number of profiles per batch (default: 10)
  • final_result: Include full result in final chunk (default: true)
  • id_source: Source for completion ID in stream chunks - "uuid" or "thread_id" (default: "uuid")
  • thread_id: Thread ID for continuation
  • uuid: UUID from a previous API call to resolve thread_id
  • insights: Enable detailed insights (1 credit/candidate)
  • high_freshness: Enable real-time updates (2 credits/candidate)
  • profile_scoring: Enable profile scoring (1 credit/candidate)
  • custom_filters: Custom filters in JSON format for advanced filtering (see CustomFilters schema for all available fields including locations, languages, titles, industries, companies, universities, keywords, experience ranges, age ranges, follower counts, degrees, and more)
  • strict_filters: Be stricter when filtering (boolean, default: false)
  • require_emails: Only return profiles with at least one email address (1 credit/candidate)
  • show_emails: Include email addresses (2 credits/candidate, only if available)
  • require_phone_numbers: Only return profiles with at least one phone number (1 credit/candidate)
  • require_phones_or_emails: Only return profiles with at least one phone number OR email address (1 credit/candidate)
  • show_phone_numbers: Include phone numbers (14 credits/candidate, only if available)
  • docid_blacklist: List of profile docids to exclude from search results
  • docid_whitelist: List of profile docids to limit search results to

Cost: (number of profiles returned) × (sum of credits for each of type, insights, profile_scoring, high_freshness, show_emails, show_phone_numbers)

Check out official Python client

Language
Credentials
Bearer
JWT