> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nonhumans.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Model Access: LLM Inference Through Nonhumans

> Access OpenAI, Anthropic, Google, and open-source LLMs through Nonhumans with unified routing, pay-as-you-go billing, and embeddings support.

Instead of managing a separate API key for every LLM provider, you route all inference through your agent's single Nonhumans API key. The models primitive gives your agent access to the full landscape of frontier and open-source models — chat completions, embeddings, and streaming — with automatic fallback and per-token billing visible in your dashboard.

## Supported Providers

<CardGroup cols={3}>
  <Card title="OpenAI" icon="circle-o">
    GPT-4o, GPT-4 Turbo, o1, o3, text-embedding-3, DALL·E
  </Card>

  <Card title="Anthropic" icon="circle-a">
    Claude 3.5 Sonnet, Claude 3.5 Haiku, Claude 3 Opus
  </Card>

  <Card title="Google" icon="circle-g">
    Gemini 1.5 Pro, Gemini 1.5 Flash, Gemini 2.0
  </Card>

  <Card title="Mistral" icon="wind">
    Mistral Large, Mistral Small, Codestral
  </Card>

  <Card title="OpenRouter" icon="shuffle">
    Unified access to 200+ models via a single route
  </Card>

  <Card title="Hugging Face" icon="face-smile">
    Open-source and fine-tuned models via serverless inference
  </Card>
</CardGroup>

***

## Chat Completions

Call any supported model with a consistent interface. Swap the `model` field to switch providers — no other changes required.

<CodeGroup>
  ```typescript TypeScript theme={null}
  const response = await agent.models.chat({
    model: 'claude-3-5-sonnet',
    messages: [
      { role: 'system', content: 'You are a helpful scheduling assistant.' },
      { role: 'user', content: 'Find a time for Alice and Bob to meet this week.' },
    ],
  });

  console.log(response.content);
  ```

  ```python Python theme={null}
  response = await agent.models.chat(
      model="claude-3-5-sonnet",
      messages=[
          {"role": "system", "content": "You are a helpful scheduling assistant."},
          {"role": "user", "content": "Find a time for Alice and Bob to meet this week."},
      ],
  )

  print(response.content)
  ```
</CodeGroup>

***

## Streaming

Enable streaming to receive tokens as they are generated, which is essential for responsive user-facing agents.

<CodeGroup>
  ```typescript TypeScript theme={null}
  const stream = await agent.models.chat({
    model: 'gpt-4o',
    messages: [{ role: 'user', content: 'Write me a project brief.' }],
    stream: true,
  });

  for await (const chunk of stream) {
    process.stdout.write(chunk.delta);
  }
  ```

  ```python Python theme={null}
  stream = await agent.models.chat(
      model="gpt-4o",
      messages=[{"role": "user", "content": "Write me a project brief."}],
      stream=True,
  )

  async for chunk in stream:
      print(chunk.delta, end="", flush=True)
  ```
</CodeGroup>

***

## Embeddings

Generate vector embeddings for any text input — pairs naturally with the [memory primitive](/primitives/memory) for building RAG pipelines.

<CodeGroup>
  ```typescript TypeScript theme={null}
  const embedding = await agent.models.embed({
    model: 'text-embedding-3-small',
    input: 'Alice prefers morning meetings and async communication.',
  });

  // embedding.vector is a Float32Array ready to store
  console.log('Dimensions:', embedding.vector.length);
  ```

  ```python Python theme={null}
  embedding = await agent.models.embed(
      model="text-embedding-3-small",
      input="Alice prefers morning meetings and async communication.",
  )

  # embedding.vector is a list of floats ready to store
  print("Dimensions:", len(embedding.vector))
  ```
</CodeGroup>

***

## How Routing Works

<Steps>
  <Step title="You specify a model">
    Pass the model name in your request. Nonhumans resolves the correct provider endpoint automatically.
  </Step>

  <Step title="Automatic fallback">
    If the primary provider returns an error or is rate-limited, Nonhumans retries with a semantically equivalent model — without requiring any changes to your code.
  </Step>

  <Step title="Cost optimization">
    For requests where you specify a capability rather than an exact model, Nonhumans routes to the lowest-cost model that meets your requirements.
  </Step>
</Steps>

<Tip>
  You don't need separate API keys for OpenAI, Anthropic, Google, or any other provider. Nonhumans handles authentication and billing on your behalf — one key, every model.
</Tip>

***

## Billing

Model usage is billed per token and charged to your Nonhumans account. Every inference call is logged with model name, token counts, and cost — visible in the dashboard under **Usage → Models**.

<Info>
  Embedding calls are billed separately from chat completions and are typically 10–20× cheaper per token. Check the dashboard for current per-model rates.
</Info>

***

## Available Parameters

### Chat

<ParamField body="model" type="string" required>
  The model identifier to use. Examples: `gpt-4o`, `claude-3-5-sonnet`, `gemini-1.5-pro`, `mistral-large`.
</ParamField>

<ParamField body="messages" type="array" required>
  An array of message objects with `role` (`system` | `user` | `assistant`) and `content` fields.
</ParamField>

<ParamField body="stream" type="boolean">
  When `true`, returns an async iterable of token chunks instead of a single response object.
</ParamField>

### Embed

<ParamField body="model" type="string" required>
  The embedding model identifier to use. Example: `text-embedding-3-small`.
</ParamField>

<ParamField body="input" type="string" required>
  The text to embed. Pass a single string to receive a single embedding vector.
</ParamField>
