GuidesSDK Guides

fetchNative — Native Format Calls

Use fetchNative to send native-format requests through the gateway with full FinOps metadata.

fetchNative — Native Format Calls

Call native-format endpoints (Anthropic Messages API, Google GenerateContent) through CoreValue Gateway and get FinOps metadata via Cova-* headers.

Tier: Available on all tiers.

When to Use fetchNative

  • You want to use the Anthropic or Google native request/response format (not OpenAI format)
  • You need FinOps metadata (cost, credits, provider) in the response
  • You don't want to use the OpenAI SDK

TypeScript

import { fetchNative, buildHeaders } from "@cova/gateway";

const { response, gateway } = await fetchNative(
  "https://gateway.corevalue.dev/v1/messages",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer sk-cova-...",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "claude-3-5-sonnet",
      messages: [{ role: "user", content: "Hello" }],
      max_tokens: 1024,
    }),
    cova: { userId: "user_123", properties: { feature: "chat" } },
  }
);

const data = await response.json();
console.log(gateway.requestId);
console.log(gateway.provider);
console.log(gateway.requestCost);
console.log(gateway.creditsRemaining);

Python

from cova_gateway import fetch_native, CovaHeaderOptions

response, gateway = fetch_native(
    "https://gateway.corevalue.dev/v1/messages",
    init={
        "method": "POST",
        "headers": {
            "Authorization": "Bearer sk-cova-...",
            "Content-Type": "application/json",
        },
        "body": '{"model": "claude-3-5-sonnet", "messages": [{"role": "user", "content": "Hello"}], "max_tokens": 1024}',
    },
    cova_opts=CovaHeaderOptions(user_id="user_123", properties={"feature": "chat"}),
)

data = response.json()
print(gateway.request_id)
print(gateway.provider)
print(gateway.request_cost)
print(gateway.credits_remaining)

fetchNative does NOT parse the response body. It returns the raw response object. You parse the body with the native SDK or response.json(). This is by design — fetchNative is a thin header helper, not a calling SDK.

Supported Native Endpoints

ProviderPathFormat
Anthropic/v1/messagesAnthropic Messages API
Google/v1beta/models/...Google GenerateContent

Cross-provider translation: If you want to send OpenAI-format requests to Anthropic/Google, use Cross-Provider Translation instead. fetchNative is for when you want to use the native format directly.

On this page