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

# Quickstart

> Make your first inference request with Tinfoil in minutes.

## Try our API

Use one of the Tinfoil SDKs to make some inference requests to an AI model. It's as easy as getting an API key and running one of our examples.

<Card title="Get an API key" icon="key" href="/get-api-key">
  You'll need a Tinfoil API key to make inference requests. Create one here.
</Card>

### Installation

Install the SDK for your language.

<Tabs>
  <Tab title="Python">
    ```bash theme={"dark"}
    pip install tinfoil
    ```
  </Tab>

  <Tab title="JavaScript">
    ```bash theme={"dark"}
    npm install tinfoil
    ```
  </Tab>

  <Tab title="Swift">
    ```swift theme={"dark"}
    // Package.swift
    dependencies: [
        .package(url: "https://github.com/tinfoilsh/tinfoil-swift.git", branch: "main")
    ]
    ```
  </Tab>

  <Tab title="Go">
    ```bash theme={"dark"}
    go get github.com/tinfoilsh/tinfoil-go
    ```
  </Tab>

  <Tab title="Rust">
    ```bash theme={"dark"}
    cargo add tinfoil --git https://github.com/tinfoilsh/tinfoil-rs
    cargo add tokio --features full
    ```
  </Tab>

  <Tab title="CLI">
    ```bash theme={"dark"}
    curl -fsSL https://github.com/tinfoilsh/tinfoil-cli/raw/main/install.sh | sh
    ```
  </Tab>
</Tabs>

### Inference

Make your first inference request with the `gpt-oss-120b` model.

<Tabs>
  <Tab title="Python">
    ```python theme={"dark"}
    import os
    from tinfoil import TinfoilAI

    client = TinfoilAI(
        api_key=os.getenv("TINFOIL_API_KEY")
    )

    chat_completion = client.chat.completions.create(
        messages=[
            {
                "role": "user",
                "content": "Hello!",
            }
        ],
        model="gpt-oss-120b",
    )
    print(chat_completion.choices[0].message.content)
    ```
  </Tab>

  <Tab title="JavaScript">
    ```typescript theme={"dark"}
    import { TinfoilAI } from "tinfoil";

    const client = new TinfoilAI({
      apiKey: process.env.TINFOIL_API_KEY
    });

    const completion = await client.chat.completions.create({
      messages: [{ role: "user", content: "Hello!" }],
      model: "gpt-oss-120b",
    });

    console.log(completion.choices[0]?.message?.content);
    ```
  </Tab>

  <Tab title="Swift">
    ```swift theme={"dark"}
    import TinfoilAI
    import OpenAI

    let client = try await TinfoilAI.create(
        apiKey: ProcessInfo.processInfo.environment["TINFOIL_API_KEY"] ?? ""
    )

    let chatQuery = ChatQuery(
        messages: [
            .user(.init(content: .string("Hello!")))
        ],
        model: "gpt-oss-120b"
    )

    let response = try await client.chats(query: chatQuery)
    print(response.choices.first?.message.content ?? "No response")
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={"dark"}
    package main

    import (
        "context"
        "fmt"
        "log"
        "os"

        "github.com/openai/openai-go/v3"
        "github.com/openai/openai-go/v3/option"
        "github.com/tinfoilsh/tinfoil-go"
    )

    func main() {
        client, err := tinfoil.NewClient(
            option.WithAPIKey(os.Getenv("TINFOIL_API_KEY")),
        )
        if err != nil {
            log.Fatal(err)
        }

        chatCompletion, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{
            Messages: []openai.ChatCompletionMessageParamUnion{
                openai.UserMessage("Hello!"),
            },
            Model: "gpt-oss-120b",
        })
        if err != nil {
            log.Fatal(err)
        }

        fmt.Println(chatCompletion.Choices[0].Message.Content)
    }
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={"dark"}
    use tinfoil::chat::{
        ChatCompletionRequestMessage, ChatCompletionRequestUserMessage,
        ChatCompletionRequestUserMessageContent, CreateChatCompletionRequestArgs,
    };
    use tinfoil::Client;

    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let client = Client::new_default().await?;

        let request = CreateChatCompletionRequestArgs::default()
            .model("gpt-oss-120b")
            .messages(vec![ChatCompletionRequestMessage::User(
                ChatCompletionRequestUserMessage {
                    content: ChatCompletionRequestUserMessageContent::Text(
                        "Hello!".to_string(),
                    ),
                    name: None,
                },
            )])
            .build()?;

        let response = client.chat().create(request).await?;
        println!("{}", response.choices[0].message.content.as_deref().unwrap_or(""));
        Ok(())
    }
    ```
  </Tab>

  <Tab title="CLI">
    ```bash theme={"dark"}
    tinfoil http post https://inference.tinfoil.sh/v1/chat/completions \
      -e inference.tinfoil.sh \
      -r tinfoilsh/confidential-model-router \
      -H "Authorization: Bearer $TINFOIL_API_KEY" \
      -H "Content-Type: application/json" \
      -b '{"model": "gpt-oss-120b", "messages": [{"role": "user", "content": "Hello!"}]}'
    ```
  </Tab>
</Tabs>

## Next steps

<CardGroup cols={2}>
  <Card title="SDK documentation" icon="book" href="/sdk/overview">
    Migration, async usage, and per-model examples across all Tinfoil SDKs.
  </Card>

  <Card title="Model catalog" icon="list" href="/models/overview">
    Browse all available AI models.
  </Card>
</CardGroup>
