Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

APIs

Crosshatch API

POST https://ai.crosshatch.io/

Creates a model response for the given context query and templated chat conversation.

Crosshatch uses different API endpoints depending on the model provider you are using.

  • Anthropic or Gemini:
    POST https://ai.crosshatch.io/
  • OpenAI:
    POST https://ai.crosshatch.io/chat/completions?api-version=2024-08-01-preview
  • Crosshatch-Replace
    : object. A JSON object that defines the context queries to be used in the messages array.
  • Crosshatch-Provider
    : string. The model that will be used to generate the response.
  • Content-Type
    : string. Must be set to
    application/json
    .
  • Authorization
    : string. The user authentication token. This short-lived token is required for all requests to the API, to authenticate your application and the user whose context you intend to reference. Get your token in Testing Sources or from the Link.

The requirements for the body of the request are dependent on the model provider you are using. All models accept templated messages

'Here is some context {context_query} and some other context {other_context_query}'

and substitute the context queries with the query responses defined in the

Crosshatch-Replace
header.

  • max_tokens
    : integer. The maximum number of tokens to generate before stopping.
  • messages
    : array. An array of templated messages to be sent to the model.
  • stream
    : boolean. If set to true, the response will be streamed as it is generated.
  • anthropic_version
    : string. Always set to
    "vertex-2023-10-16"
// Request body { "anthropic_version": "vertex-2023-10-16", "messages": [ { "role": "user", "content": "Consider context {context_query}. What should I do next?" } ], "max_tokens": 50, "stream": false } // Response body { "id": "msg_vrtx_019vSbjYDYwZNjxqk5AXYLzF", "type": "message", "role": "assistant", "model": "claude-3-haiku-20240307", "content": [ { "type": "text", "text": "You should lock in." } ], "stop_reason": "max_tokens", "stop_sequence": null, "usage": { "input_tokens": 2523, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0, "output_tokens": 5 } }

You can see other available parameters in the Anthropic documentation.

// Request body { "messages": [ { "role": "system", "content": "Consider the user's past hotel stays {hotel_history}" }, { "role": "user", "content": "Summarize the top 5 hotel vibes the user likes" } ], "response_format": { "type": "json_object" } } // Response body { "id": "chatcmpl-1234", "object": "chat.completion", "created": 1740450285, "model": "gpt-4o-2024-11-20", "system_fingerprint": "fp_b705f0c291", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "The users top 5 hotel vibes are: Bathrobe Connoiseur, Really Really Late Checkout, Minibar Raider Platinum, Spa Creatures, Do Not Disturb Ever", "refusal": null }, "logprobs": null, "finish_reason": "stop", "content_filter_results": { } } ], "usage": { "prompt_tokens": 1686, "prompt_tokens_details": { "cached_tokens": 0, "audio_tokens": 0 }, "completion_tokens": 1254, "completion_tokens_details": { "accepted_prediction_tokens": 0, "rejected_prediction_tokens": 0, "reasoning_tokens": 0, "audio_tokens": 0 }, "total_tokens": 2940 }, "prompt_filter_results": [ ] }

You can see the available parameters in the OpenAI documentation including its capability to create structured outputs.

// Request body { "contents": [ { "role": "user", "parts": [{ "text": "Consider the users recent spending {recent_travel}. Where should they travel next?" }] } ] } // Streaming Response (simplified) // First chunk { "candidates": [ { "content": { "role": "model", "parts": [ { "text": "They" } ] }, "safetyRatings": [ // Safety ratings truncated for brevity ] } ], "modelVersion": "gemini-1.5-flash-001", "responseId": "hi69Z5CiC9HSptQPptOHSQ" } // Final chunk { "candidates": [ { "content": { "role": "model", "parts": [ { "text": "should definitely travel to Miami." } ] }, "finishReason": "STOP" // Safety ratings omitted for brevity } ], "usageMetadata": { "promptTokenCount": 2105, "candidatesTokenCount": 25, "totalTokenCount": 2130 // Token details omitted for brevity }, "modelVersion": "gemini-1.5-flash-001", "responseId": "hi69Z5CiC9HSptQPptOHSQ" } // Note: Each chunk contains a portion of the full response. // Client applications should concatenate the text from each chunk. // The complete concatenated text would form a complete response.

Crosshatch supports the following models, hosted in our virtual private cloud. You can reference them by their name indicated below.

ProviderModel NameModel Docs
Anthropic
claude-3-haiku
Link
Anthropic
claude-3-5-sonnet
Link
OpenAI
gpt-4o
Link
OpenAI
gpt-4o-mini
Link
Google
gemini-1.5-flash-001
Link
Google
gemini-1.5-pro-001
Link

You can see our model pricing on our pricing page.

User authentication tokens (for Production and Testing Users) are short-lived:

  • 2 hours for Testing Users
  • 5 minutes for Production Users

Error handling is currently limited.