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

# क्विकस्टार्ट

> API कुंजी बनाएँ और मौजूदा टेक्स्ट मॉडल के साथ Phaseo को अपना पहला अनुरोध भेजें।

इस ट्यूटोरियल से सफल Phaseo अनुरोध करें—जनरेट किया गया टेक्स्ट या संरचित निर्णय—और देखें कि प्रतिक्रिया कहाँ आती है।

<Note>
  **कोडिंग एजेंट इस्तेमाल कर रहे हैं?** शुरू करने से पहले यह प्रॉम्प्ट कॉपी और पेस्ट करें:

  ```text theme={null}
  You are integrating this project with Phaseo Gateway. Read the Phaseo agent guidance at https://phaseo.app/docs/skill.md and the relevant API reference before editing anything. Inspect the existing provider configuration and identify the smallest safe change needed. Use https://api.phaseo.app with a server-side PHASEO_API_KEY, preserve the current provider/model behavior unless I explicitly ask for a migration, and never print or commit credentials. Explain the files you would change and the verification commands first. Do not deploy, rotate keys, send external messages, or make unrelated edits without my approval.
  ```
</Note>

इसमें आप:

* API कुंजी बनाएँगे
* टेक्स्ट अनुरोध या संरचित निर्णय भेजना
* जनरेट टेक्स्ट या प्रकारयुक्त उत्तर पढ़ना
* अनुरोध विफल होने पर पहले क्या जाँचना है, यह जानेंगे

***

## 1. API कुंजी बनाएँ

1. [Phaseo डैशबोर्ड](https://phaseo.app/gateway/keys) खोलें।
2. **Gateway -> कुंजियाँ** के अंतर्गत एक कुंजी बनाएँ।
3. इसे एक बार कॉपी करें और सुरक्षित रखें।

इस फ़ॉर्मैट का उपयोग करें:

```http theme={null}
Authorization: Bearer phaseo_v1_sk_<kid>_<secret>
```

<Danger>
  API कुंजी को पासवर्ड की तरह सुरक्षित रखें। इसे क्लाइंट-साइड कोड में न रखें।
</Danger>

***

## 2. टेक्स्ट अनुरोध भेजें

पहले अनुरोध के लिए `POST /v1/responses` इस्तेमाल करें। नए टेक्स्ट जनरेशन इंटीग्रेशन के लिए यही सुझाया गया endpoint है।

### अनुरोध

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.phaseo.app/v1/responses \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "openai/gpt-6-astra",
      "input": "Reply with: quickstart works"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.phaseo.app/v1/responses", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "openai/gpt-6-astra",
      input: "Reply with: quickstart works",
    }),
  });

  const data = await response.json();
  const assistantText = data.output
    ?.find((item) => item.type === "message")
    ?.content?.find((part) => part.type === "output_text")
    ?.text;

  console.log(assistantText);
  ```

  ```typescript TypeScript SDK theme={null}
  import Phaseo from "@phaseo/sdk";

  const client = new Phaseo({ apiKey: process.env.PHASEO_API_KEY! });

  const response = await client.generateResponse({
    model: "openai/gpt-6-astra",
    input: "Reply with: quickstart works",
  });

  const assistantText = response.output
    ?.find((item: any) => item.type === "message")
    ?.content?.find((part: any) => part.type === "output_text")
    ?.text;

  console.log(assistantText);
  ```

  ```python Python SDK theme={null}
  from phaseo import Phaseo

  client = Phaseo(api_key="YOUR_API_KEY")

  response = client.generate_response(
      {
          "model": "openai/gpt-6-astra",
          "input": "Reply with: quickstart works",
      }
  )

  assistant_text = next(
      (
          part.get("text")
          for item in response.get("output", [])
          if item.get("type") == "message"
          for part in item.get("content", [])
          if part.get("type") == "output_text"
      ),
      None,
  )

  print(assistant_text)
  ```

  ```go Go SDK theme={null}
  package main

  import (
    "context"
    "fmt"

    phaseo "github.com/phaseoteam/Phaseo/packages/sdk/sdk-go/v3"
  )

  func main() {
    client := phaseo.New("YOUR_API_KEY", "https://api.phaseo.app/v1")
    input := map[string]interface{}{
      "role": "user",
      "content": []map[string]interface{}{
        {
          "type": "input_text",
          "text": "Reply with: quickstart works",
        },
      },
    }

    response, err := client.GenerateResponse(context.Background(), phaseo.ResponsesRequest{
      Model: "openai/gpt-6-astra",
      Input: &input,
    })
    if err != nil {
      panic(err)
    }

    fmt.Println(response)
  }
  ```

  ```csharp C# SDK theme={null}
  using PhaseoSdk;
  using System.Collections.Generic;

  var client = new Phaseo("YOUR_API_KEY");

  var response = await client.GenerateResponse(new Dictionary<string, object>
  {
      ["model"] = "openai/gpt-6-astra",
      ["input"] = "Reply with: quickstart works",
  });

  Console.WriteLine(response);
  ```

  ```php PHP SDK theme={null}
  <?php
  require 'vendor/autoload.php';

  use Phaseo\Sdk\Phaseo;

  $client = new Phaseo(getenv('PHASEO_API_KEY') ?: 'YOUR_API_KEY');

  $response = $client->generateResponse([
      'model' => 'openai/gpt-6-astra',
      'input' => 'Reply with: quickstart works',
  ]);

  print_r($response);
  ```

  ```ruby Ruby SDK theme={null}
  require 'phaseo_sdk'

  client = PhaseoSdk::Phaseo.new(api_key: ENV.fetch('PHASEO_API_KEY', 'YOUR_API_KEY'))

  response = client.generate_response(
    model: 'openai/gpt-6-astra',
    input: 'Reply with: quickstart works',
  )

  puts response
  ```

  ```rust Rust SDK theme={null}
  use phaseo::Phaseo;
  use serde_json::{json, Value};

  fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = Phaseo::from_env()?;
      let response = client.responses(&json!({
          "model": "openai/gpt-6-astra",
          "input": "Reply with: quickstart works"
      }))?;

      let assistant_text = response.body
          .get("output")
          .and_then(Value::as_array)
          .into_iter()
          .flatten()
          .filter(|item| item.get("type").and_then(Value::as_str) == Some("message"))
          .flat_map(|item| {
              item.get("content")
                  .and_then(Value::as_array)
                  .into_iter()
                  .flatten()
          })
          .find_map(|part| {
              (part.get("type").and_then(Value::as_str) == Some("output_text"))
                  .then(|| part.get("text").and_then(Value::as_str))
                  .flatten()
          })
          .unwrap_or("");

      println!("{assistant_text}");
      Ok(())
  }
  ```

  ```typescript Vercel AI SDK theme={null}
  import { phaseo } from "@phaseo/ai-sdk-provider";
  import { generateText } from "ai";

  const result = await generateText({
    model: phaseo("openai/gpt-6-astra"),
    prompt: "Reply with: quickstart works",
  });

  console.log(result.text);
  ```
</CodeGroup>

### जवाब

```json theme={null}
{
  "id": "resp_...",
  "object": "response",
  "created_at": 1730000000,
  "status": "completed",
  "completed_at": 1730000001,
  "model": "openai/gpt-6-astra",
  "output": [
    {
      "type": "message",
      "id": "msg_...",
      "status": "completed",
      "role": "assistant",
      "content": [{ "type": "output_text", "text": "quickstart works", "annotations": [] }]
    }
  ],
  "usage": {
    "input_tokens": 9,
    "output_tokens": 3,
    "total_tokens": 12
  },
  "error": null,
  "incomplete_details": null
}
```

Responses API को सीधे कॉल करने पर असिस्टेंट का जवाब `output[].content[]` में उस आइटम से पढ़ें जिसका `type` `output_text` है।

अगर आप Vercel AI SDK इस्तेमाल करते हैं, तो जवाब `result.text` से पढ़ें।

***

## 3. संरचित निर्णय लें

ऐप्लिकेशन को जनरेट टेक्स्ट की जगह प्रकारयुक्त उत्तर चाहिए तो `POST /v1/decisions` इस्तेमाल करें। Phaseo TypeSafe का Jev 1.13 मॉडल ID `typesafe/jev-1.13.0` से देता है। `state` मान और एक या अधिक नामित प्रश्न भेजें; हर उत्तर उसी नाम से लौटता है।

<Note>
  Decisions बीटा सुविधा है और कार्यक्षेत्र में सक्षम करना पड़ सकता है। Jev 1.13 का शुल्क प्रति 10 लाख इनपुट टोकन \$0.042 है; आउटपुट टोकन मुफ़्त हैं।
</Note>

`PHASEO_API_KEY` सेट करके ये उदाहरण सर्वर पर चलाएँ। ब्राउज़र कोड में Gateway API कुंजी कभी न दिखाएँ।

तीन प्रश्न प्रकार हैं:

* `choice` मानदंड मैप से एक विकल्प चुनता है और संभावनाएँ व विश्वास लौटाता है।
* `noul` 0 से 1 तक हाँ/नहीं की संभावना लौटाता है।
* `score` क्रमबद्ध मानदंड ऐरे का मूल्यांकन करता है और संभावना-भारित स्कोर लौटाता है।

एक ही अनुरोध में अलग प्रश्न प्रकार मिला सकते हैं।

### अनुरोध

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.phaseo.app/v1/decisions \
    -H "Authorization: Bearer $PHASEO_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "typesafe/jev-1.13.0",
      "state": {
        "customer_message": "I was charged twice and need help with a refund.",
        "account_tier": "pro",
        "days_waiting": 3
      },
      "questions": {
        "department": {
          "type": "choice",
          "instructions": "Which team should handle this request?",
          "criteria": {
            "billing": "Payments, invoices, refunds, and duplicate charges.",
            "support": "Product usage questions and troubleshooting.",
            "sales": "Upgrades and new accounts."
          }
        },
        "is_urgent": {
          "type": "noul",
          "instructions": "Does this request require urgent handling?",
          "criteria": {
            "true": "The customer is blocked or the issue is time-sensitive.",
            "false": "The request can follow the normal support queue."
          }
        },
        "customer_impact": {
          "type": "score",
          "instructions": "How severe is the customer impact?",
          "criteria": [
            "No impact",
            "Minor inconvenience",
            "Significant impact",
            "Service blocked"
          ]
        }
      }
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.phaseo.app/v1/decisions", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.PHASEO_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "typesafe/jev-1.13.0",
      state: {
        customer_message: "I was charged twice and need help with a refund.",
        account_tier: "pro",
        days_waiting: 3,
      },
      questions: {
        department: {
          type: "choice",
          instructions: "Which team should handle this request?",
          criteria: {
            billing: "Payments, invoices, refunds, and duplicate charges.",
            support: "Product usage questions and troubleshooting.",
            sales: "Upgrades and new accounts.",
          },
        },
        is_urgent: {
          type: "noul",
          instructions: "Does this request require urgent handling?",
          criteria: {
            true: "The customer is blocked or the issue is time-sensitive.",
            false: "The request can follow the normal support queue.",
          },
        },
        customer_impact: {
          type: "score",
          instructions: "How severe is the customer impact?",
          criteria: [
            "No impact",
            "Minor inconvenience",
            "Significant impact",
            "Service blocked",
          ],
        },
      },
    }),
  });

  if (!response.ok) throw new Error(await response.text());
  const data = await response.json();
  console.log(data.answers);
  ```

  ```typescript TypeScript SDK theme={null}
  import Phaseo from "@phaseo/sdk";

  const client = new Phaseo({ apiKey: process.env.PHASEO_API_KEY! });

  const decision = await client.decisions.make({
    model: "typesafe/jev-1.13.0",
    state: {
      customer_message: "I was charged twice and need help with a refund.",
      account_tier: "pro",
      days_waiting: 3,
    },
    questions: {
      department: {
        type: "choice",
        instructions: "Which team should handle this request?",
        criteria: {
          billing: "Payments, invoices, refunds, and duplicate charges.",
          support: "Product usage questions and troubleshooting.",
          sales: "Upgrades and new accounts.",
        },
      },
      is_urgent: {
        type: "noul",
        instructions: "Does this request require urgent handling?",
        criteria: {
          true: "The customer is blocked or the issue is time-sensitive.",
          false: "The request can follow the normal support queue.",
        },
      },
      customer_impact: {
        type: "score",
        instructions: "How severe is the customer impact?",
        criteria: [
          "No impact",
          "Minor inconvenience",
          "Significant impact",
          "Service blocked",
        ],
      },
    },
  });

  console.log(decision.answers);
  ```

  ```python Python SDK theme={null}
  from phaseo import Phaseo

  client = Phaseo()  # Uses PHASEO_API_KEY from the environment

  decision = client.decisions.make(
      {
          "model": "typesafe/jev-1.13.0",
          "state": {
              "customer_message": "I was charged twice and need help with a refund.",
              "account_tier": "pro",
              "days_waiting": 3,
          },
          "questions": {
              "department": {
                  "type": "choice",
                  "instructions": "Which team should handle this request?",
                  "criteria": {
                      "billing": "Payments, invoices, refunds, and duplicate charges.",
                      "support": "Product usage questions and troubleshooting.",
                      "sales": "Upgrades and new accounts.",
                  },
              },
              "is_urgent": {
                  "type": "noul",
                  "instructions": "Does this request require urgent handling?",
                  "criteria": {
                      "true": "The customer is blocked or the issue is time-sensitive.",
                      "false": "The request can follow the normal support queue.",
                  },
              },
              "customer_impact": {
                  "type": "score",
                  "instructions": "How severe is the customer impact?",
                  "criteria": [
                      "No impact",
                      "Minor inconvenience",
                      "Significant impact",
                      "Service blocked",
                  ],
              },
          },
      }
  )

  print(decision["answers"])
  ```
</CodeGroup>

### प्रतिक्रिया

```json theme={null}
{
  "model": "typesafe/jev-1.13.0",
  "answers": {
    "department": {
      "type": "choice",
      "choice": "billing",
      "probabilities": { "billing": 0.91, "support": 0.06, "sales": 0.03 },
      "confidence": 0.89
    },
    "is_urgent": {
      "type": "noul",
      "noul": 0.84
    },
    "customer_impact": {
      "type": "score",
      "score": 2.4,
      "legend": {
        "0": "No impact",
        "1": "Minor inconvenience",
        "2": "Significant impact",
        "3": "Service blocked"
      },
      "probabilities": { "0": 0.02, "1": 0.12, "2": 0.61, "3": 0.25 },
      "confidence": 0.76
    }
  },
  "usage": {
    "input_tokens": 42,
    "output_tokens": 18,
    "total_tokens": 60
  }
}
```

प्रश्न ID से मेल खाने वाले उत्तर से प्रकारयुक्त मान पढ़ें, जैसे `answers.department.choice`, `answers.is_urgent.noul` या `answers.customer_impact.score`। केवल मान से निर्णय लेने के बजाय ऐप्लिकेशन सीमा तय करने के लिए `confidence` और `probabilities` इस्तेमाल करें।

पूरे अनुरोध और प्रतिक्रिया अनुबंध के लिए [Decisions API संदर्भ](./api-reference/endpoint/decisions), और मॉडल व्यवहार व प्रदाता सीमाओं के लिए TypeSafe का [Jev मॉडल संदर्भ](https://docs.typesafe.ai/models) देखें।

***

## 4. पहले अनुरोध की समस्या हल करें

* `401`: API कुंजी और `Authorization` हेडर जाँचें।
* `400`: अनुरोध बॉडी और मॉडल ID जाँचें।
* `402`: `:free` मॉडल चुनें या पेड मॉडल इस्तेमाल करने से पहले क्रेडिट जोड़ें।
* `429` या `5xx`: एक्सपोनेंशियल बैकऑफ़ के साथ फिर कोशिश करें।

समस्या जल्दी ढूँढ़ने के लिए [त्रुटि प्रबंधन संदर्भ](./api-reference/errors.mdx) देखें।

***

## 5. अगर आप वीडियो बना रहे हैं

वीडियो जनरेशन एसिंक्रोनस है। पहले job बनाएँ, फिर उसका स्टेटस पूछें या नतीजे के लिए subscribe करें।

1. `POST /v1/videos` से job बनाएँ।
2. पूरा होने तक `GET /v1/videos/{video_id}` से स्टेटस पूछें।
3. `GET /v1/videos/{video_id}/content` से सामग्री डाउनलोड करें।

```bash theme={null}
# Create
curl https://api.phaseo.app/v1/videos \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<video-model-id>",
    "prompt": "A cinematic sunrise over a mountain lake"
  }'

# Poll status
curl https://api.phaseo.app/v1/videos/VIDEO_ID \
  -H "Authorization: Bearer YOUR_API_KEY"
```

***

## 6. आगे बनाते रहें

<Columns cols={2}>
  <Card title="Gateway के साथ इंटीग्रेशन" icon="plug" href="./developers/integrating-with-the-gateway.mdx">
    प्रोडक्शन इंटीग्रेशन के तरीके और endpoint चुनने की जानकारी।
  </Card>

  <Card title="API संदर्भ" icon="book" href="./api-reference/introduction.mdx">
    हर endpoint के अनुरोध और जवाब का पूरा दस्तावेज़।
  </Card>

  <Card title="उदाहरण" icon="code" href="./guides/examples.mdx">
    आम वर्कफ़्लो के लिए और विस्तृत अनुरोध उदाहरण।
  </Card>

  <Card title="सहायता" icon="message-circle" href="https://phaseo.app/help">
    डिबगिंग, रूटिंग और मॉडल के व्यवहार में मदद पाएँ।
  </Card>
</Columns>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.