Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • The available models
  • The API Limitation
  • How to test this API & get an API Key
  • What would be the best Model to use & pricing Pricing to follow
  • The number of tokens that should be used in our prompt to prevent errors


Expand
titleThe available models

GPT : Generative Pre-trained Transformer 

Expand
titleGPT-4
  • Latest model
  • With broad general knowledge and domain expertise, GPT-4 can follow complex instructions in natural language and solve difficult problems with with greater accuracy.
  • is more creative and collaborative than ever before. It can generate, edit, and iterate with users on creative and technical writing tasks, such as composing songs, writing screenplays, or learning a user’s writing style.

  • Following the research path from GPT, GPT-2, and GPT-3, the deep learning approach leverages more data and more computation to create increasingly sophisticated and capable language models
  • 6 months were spent making GPT-4 safer and more aligned.

  • GPT-4 is 82% less likely to respond to requests for disallowed content and 40% more likely to produce factual responses than GPT-3.5 on our internal evaluations.

  • Price list for GPT-4  (Multiple models, each with different capabilities and price points. Prices are per 1,000 tokens. You can think of tokens as pieces of words, where 1,000 tokens is about 750 words.)

    ModelPromptCompletion
    8K context$0.03 / 1K tokens$0.06 / 1K tokens
    32K context$0.06 / 1K tokens$0.12 / 1K tokens
  • GPT-4 models

    LATEST MODELDESCRIPTIONMAX TOKENSTRAINING DATA
    gpt-4More capable than any GPT-3.5 model, able to do more complex tasks, and optimized for chat. Will be updated with our latest model iteration.8,192 tokensUp to Sep 2021
    gpt-4-0314Snapshot of gpt-4 from March 14th 2023. Unlike gpt-4, this model will not receive updates, and will only be supported for a three month period ending on June 14th 2023.8,192 tokensUp to Sep 2021
    gpt-4-32kSame capabilities as the base gpt-4 mode but with 4x the context length. Will be updated with our latest model iteration.32,768 tokensUp to Sep 2021
    gpt-4-32k-0314Snapshot of gpt-4-32 from March 14th 2023. Unlike gpt-4-32k, this model will not receive updates, and will only be supported for a three month period ending on June 14th 2023.32,768 tokensUp to Sep 2021


    For many basic tasks, the difference between GPT-4 and GPT-3.5 models is not significant. However, in more complex reasoning situations, GPT-4 is much more capable than any of our previous models.

  • Limitation:

          GPT-4 is currently in a limited beta and only accessible to those who have been granted access. In order to use this API we need to join the waitlist to get access when capacity is available.

Expand
titleGPT-3.5

GPT-3.5 models can understand and generate natural language or code. Our most capable and cost effective model in the GPT-3.5 family is gpt-3.5-turbo which has been optimized for chat but works well for traditional completions tasks as well.

LATEST MODELDESCRIPTIONMAX TOKENSTRAINING DATA
gpt-3.5-turboMost capable GPT-3.5 model and optimized for chat at 1/10th the cost of text-davinci-003. Will be updated with our latest model iteration.4,096 tokensUp to Sep 2021
gpt-3.5-turbo-0301Snapshot of gpt-3.5-turbo from March 1st 2023. Unlike gpt-3.5-turbo, this model will not receive updates, and will only be supported for a three month period ending on June 1st 2023.4,096 tokensUp to Sep 2021
text-davinci-003text
  • text-davinci-003 is an advanced language model developed by OpenAI.
  • Can do any language task with better quality, longer output, and consistent instruction-following than the curie, babbage, or ada models. Also supports inserting completions within text.
4,097 tokensUp to Jun 2021
002
Similar capabilities to text-davinci-003 but trained with supervised fine-tuning instead of reinforcement learning4,097 tokensUp to Jun 2021
code-davinci-002

Optimized for code-completion tasks

Now deprecated

8,001 tokensUp to Jun 2021

Recommendation to use gpt-3.5-turbo over the other GPT-3.5 models because of its lower cost.

Experimenting with gpt-3.5-turbo is a great way to find out what the API is capable of doing. After you have an idea of what you want to accomplish, you can stay with gpt-3.5-turbo or another model and try to optimize around its capabilities.

Note: OpenAI models are non-deterministic, meaning that identical inputs can yield different outputs. Setting temperature to 0 will make the outputs mostly deterministic, but a small amount of variability may remain.

Expand
titleGPT-3
  • GPT-3 models can understand and generate natural language.
  • These models were superceded by the more powerful GPT-3.5 generation models.
  • However, the original GPT-3 base models (davinci, curie, ada, and babbage) are current the only models that are available to fine-tune.
  • Fine-tuning mean to build and train our own data from one of GPT-3 Models
Expand
titleWhat would be the best Model to use
  • We can use the GPT comparison tool that lets us run different models side-by-side to compare outputs, settings, and response times and then download the data into an Excel spreadsheet.
  • Under the examples section, we can benefit from examples to choose what we want
  • For example we can use text-davinci-003 for SQL Translation

          Image Removed

          Image Removed

  • Other example we can benefit from, to reduce the email content, before sending it in the prompt:  using text-davinci-003

          For sure we need to test how limited the # of tokens in this example prompt itself

         Image Removed                                                   or                    Image Removed

         Image Removed                                                Image Removed

  • For retrieving data from the email we can try one of these examples: using text-davinci-003

         Image Removed                            or                      Image Removed

         Image Removed                                                Image Removed

4,097 tokensUp to Jun 2021
text-davinci-002Similar capabilities to text-davinci-003 but trained with supervised fine-tuning instead of reinforcement learning4,097 tokensUp to Jun 2021
code-davinci-002

Optimized for code-completion tasks

Now deprecated

8,001 tokensUp to Jun 2021

Models referred to as "GPT 3.5"

GPT-3.5 series is a series of models that was trained on a blend of text and code from before Q4 2021. The following models are in the GPT-3.5 series:

    1. code-davinci-002 is a base model, so good for pure code-completion tasks
    2. text-davinci-002 is an InstructGPT model based on code-davinci-002
    3. text-davinci-003 is an improvement on text-davinci-002
    4. gpt-3.5-turbo-0301 is an improvement on text-davinci-003, optimized for chat


Recommendation to use gpt-3.5-turbo over the other GPT-3.5 models because of its lower cost.

Experimenting with gpt-3.5-turbo is a great way to find out what the API is capable of doing. After you have an idea of what you want to accomplish, you can stay with gpt-3.5-turbo or another model and try to optimize around its capabilities.

Note: OpenAI models are non-deterministic, meaning that identical inputs can yield different outputs. Setting temperature to 0 will make the outputs mostly deterministic, but a small amount of variability may remain.

Image Added



Expand
titleGPT-3
  • GPT-3 models can understand and generate natural language.
  • These models were superceded by the more powerful GPT-3.5 generation models.
  • However, the original GPT-3 base models (davinci, curie, ada, and babbage) are current the only models that are available to fine-tune.
  • Fine-tuning mean to build and train our own data from one of GPT-3 Models
  • Prices:

         Image Added

Expand
titletext-davinci-002 vs text-davinci-003
  • Enhanced Capabilities of davinci-text-003

The main difference between davinci-text-002 and davinci-text-003 is that the latter has been trained on a larger dataset, allowing it to generate more accurate results. Additionally, text-davinci-003 can better understand natural language instructions and produce more detailed responses. It also has improved capabilities for summarizing long documents and generating coherent paragraphs from multiple sources. Furthermore, OpenAI claims that text-davinci-003 can generate longer content with greater clarity, and engagement.


  • Strengths and Weaknesses of Each Model

The output from davinci-text-002 was a series of short, concise sentences that were easy to read and understand. On the other hand, davinci-text-003 produced longer, more complex sentences with more intricate language. Both outputs had their own unique style and could be used for different purposes depending on the context. It is clear that both algorithms have their strengths and weaknesses when it comes to text generation. Note: ‘003 takes longer than the previous version to process prompts.

  • text-davinci-003 includes the following improvements:

    • It produces higher quality writing. This will help your applications deliver clearer, more engaging, and more compelling content.
    • It can handle more complex instructions, meaning you can get even more creative with how you make use of its capabilities now.
    • It’s better at longer form content generation, allowing you to take on tasks that would have previously been too difficult to achieve.
    Expand
    titleTo illustrate the improvements, check out the following example:
    • text-davinci-002:

    Prompt: "I am trying to write a web application. What backend frameworks could I use, and what are their pros and cons?"

    There are many backend frameworks that could be used for a web application. Some popular one

    • text-davinci-003:

    Prompt: "I am trying to write a web application. What backend frameworks could I use, and what are their pros and cons?"

    1.  Node.js: Node.js is a JavaScript-based runtime environment that is popular for writing backend applications. Pros: Node.js is fast, lightweight, and easy to learn, and it has a large community of developers. Cons: Node.js can be difficult to debug and there is a lack of robust tools for building large-scale applications. 2.  Django: Django is a popular Python-based web framework. Pros: Django is powerful and well-documented, making it easy to get started. It also supports a wide range of databases and APIs, allowing you to easily integrate with other services. Cons: Django can be difficult to scale for large applications and can be slow for certain types of requests.3.  Ruby on Rails: Ruby on Rails is a popular web framework based on the Ruby programming language. Pros: Ruby on Rails is easy to learn and can be used to quickly build powerful web applications. It also has a wide range of built-in features, such as authentication and authorization. Cons: Ruby on Rails can be slow and resource-intensive, and it can be difficult to scale. text-davinci-003 can be accessed through openai API and Playground at the same price as other Davinci base language models.

    Users can access `text-davinci-003` through the Open AI API and playground, at the same price as their other Davinci base language models ($0.0200 / 1k tokens). 

Expand
titleGpt-3.5-turbo vs text-davinci-003
  • OpenAI's new GPT-3.5 Turbo model offers a cost-effective option for many non-chat use cases.
  • While GPT-3.5 Turbo performs well in 0-shot classification and math, Davinci-003 performs slightly better in k-shot classification and may be a better option for those looking for clear, concise responses that get straight to the point.
  • Comparison for different tasks, can be found here
    • Expand
      titleClassification

      From our previous experiments, we concluded that Davinci-003 performed much better than Davinci-002 with 0 shot prompts (92% vs 69.91%), and on par or slightly worse than Davinci-002 on few shot prompts (87.2% vs 91.6%). We observe a similar case with GPT-3.5 Turbo and Davinci-003.

      GPT-3.5 Turbo performs better on 0 shot classification- on an insider trading classification example it achieves 91.72% accuracy, versus 82.02% for Davinci-003.

    • Expand
      titleText Generation

      If you're looking for an AI language model that can generate long, detailed answers to complex questions, GPT-3.5 Turbo might seem like the obvious choice since it's been trained on a massive dataset of human language and produces coherent, contextually-appropriate responses.

      But what if you're looking for a model that can provide clear, concise responses? In that case, you might want to consider using Davinci-003 instead.

      In our experiment, we provided both GPT-3.5 Turbo and Davinci-003 with a set of 30 questions, and asked each model to provide 30 answers. What we found was that GPT-3.5 Turbo’s responses tended to be much longer than Davinci-003's, with many of them exceeding 100 words. In contrast, Davinci-003's responses were much more concise, often consisting of just a few sentences. Given a max tokens of 500, the average response from GPT-3.5 Turbo was 156 words (~208 tokens) nearly twice the amount of Davinci-003, whose responses were an average of 83 words (~111 tokens).

    • Expand
      titleMath

      Notably, GPT-3.5 Turbo is significantly better than Davinci-003 at math. When evaluating by exact match with an answer key, GPT-3.5 Turbo gets the correct numerical answer 75% of the time, while Davinci-003 only gets 61% correct.

    • Overall, GPT-3.5 Turbo performs better than Davinci-003 on most tasks at 10% of the cost - but is much more rambly. You can test out whether GPT-3.5 Turbo is better for your use case through Spellbook - sign up today.

Expand
titleGPT-4 vs. ChatGPT-3.5
  • GPT4 and GPT-3.5-turb API cost comparison and understanding
  • Below you can find a list of references links:
  • Expand
    titleWhat Is GPT 3.5?

    GPT 3.5 is, as the name suggests, a sort of bridge between GPT-3 and GPT-4. OpenAI hasn’t really been particularly open about what makes GPT 3.5 specifically better than GPT 3, but it seems that the main goals were to increase the speed of the model and perhaps most importantly to reduce the cost of running it.

    Interestingly, what OpenAI has made available to users isn’t the raw core GPT 3.5, but rather several specialized offshoots. For example, GPT 3.5 Turbo is a version that’s been fine-tuned specifically for chat purposes, although it can generally still do all the other things GPT 3.5 can.

  • Expand
    titleWhat Is GPT 4?

    OpenAI’s GPT-4 has emerged as their most advanced language model yet, offering safer and more effective responses. This cutting-edge, multimodal system accepts both text and image inputs and generates text outputs, showcasing human-level performance on an array of professional and academic benchmarks.

    When comparing GPT-3 and GPT-4, the difference in their capabilities is striking. GPT-4 has enhanced reliability, creativity, and collaboration, as well as a greater ability to process more nuanced instructions. This marks a significant improvement over the already impressive GPT-3, which often made logic and other reasoning errors with more complex prompts.

    Expand
    titleOther differences:
    • Another key distinction between the two models lies in their size. GPT-3 boasts a remarkable 175 billion parameters, while GPT-4 takes it a step further with a (rumored) 1 trillion parameters.

      • GPT-4is 10 times more advanced than its predecessor, GPT-3.5. This enhancement enables the model to better understand context and distinguish nuances, resulting in more accurate and coherent responses.

      • Furthermore, GPT-4has a maximum token limit of 32,000 (equivalent to 25,000 words), which is a significant increase from GPT-3.5’s 4,000 tokens (equivalent to 3,125 words).


    • While GPT-4 is not perfect, the measures it adopts to ensure safer responses are a welcomed upgrade from that of the GPT-3.5 model. With GPT-3.5, OpenAI took a more moderation-based approach to safety. In other words, some of the safety measures were more of an afterthought. OpenAI monitored what users did and the questions they asked, identified flaws, and tried to fix them on the go.


    • One of GPT-3.5's flaws is its tendency to produce nonsensical and untruthful information confidently. In AI lingo, this is called "AI hallucination" and can cause distrust of AI-generated information. In GPT-4, hallucination is still a problem. However, according to the GPT-4 technical report, the new model is 19% to 29% less likely to hallucinate when compared to the GPT-3.5 model. But this isn't just about the technical report. Responses from the GPT-4 model on ChatGPT are noticeably more factual.


    • A less talked about difference between GPT-4 and GPT-3.5 is the context window and context size. A context window is how much data a model can retain in its "memory" during a chat session and for how long. GPT-4 has a significantly better context size and window than its predecessor model.


    • Another issue is the limitation on the volume of text you can use in a prompt at once. Summarizing long text using GPT-3 typically means splitting the text into multiple chunks and summarizing them bit by bit. The improvement in context length in the GPT-4 model means you can paste entire PDFs at a go and get the model to summarize without splitting it into chunks.


    • GPT-4 has a much larger model size, which means it can handle more complex tasks and generate more accurate responses. This is thanks to its more extensive training dataset, which gives it a broader knowledge base and improved contextual understanding.


    • GPT-4 is better equipped to handle longer text passages, maintain coherence, and generate contextually relevant responses. For this reason, it’s an incredibly powerful tool for natural language understanding applications. It’s so complex, some researchers from Microsoft think it’s shows “Sparks of Artificial General Intelligence” or AGI.


    • But there’s a downside, as with any cutting-edge technology. The significant advancements in GPT-4 come at the cost of increased computational power requirements. This makes it less accessible to smaller organizations or individual developers who may not have the resources to invest in such a high-powered machine.

  • Expand
    titleWhen Should You Use GPT 3.5 or GPT 4?
    • Whether you’re building your own GPT-based app or using ChatGPT and have a choice between GPT 3.5 and 4, there are some use cases where GPT 3.5, despite being objectively inferior to GPT-4, is a better choice:

      • If you’re limited in terms of computing power, GPT 3.5 is significantly cheaper to run.
      • Although GPT-4 is less likely to “hallucinate” or make factual errors than GPT 3.5, it takes the same amount of time for a human to fact-check and edit the text. So if speed is the priority, the older model might be the better choice.

      But there are good reasons to GPT 4 as well:

      • If you need GPT to do anything that requires complex reasoning, you’ll want to use GPT-4 every time.
      • If you need GPT to process more than 3000 words at once, you’ll have to go with GPT-4.

      Over time, as computing power becomes more powerful and less expensive, while GPT-4 and it’s successors become more efficient and refined, it’s likely that GPT-4 will replace GPT 3.5 in every situation. Until then, you’ll have to choose the model that best suits your resources and needs.

  • Expand
    titleMore

    GPT-4 models (preview)

    GPT-4 can solve difficult problems with greater accuracy than any of OpenAI's previous models. Like gpt-35-turbo, GPT-4 is optimized for chat but works well for traditional completions tasks.

    These models are currently in preview. For access, existing Azure OpenAI customers can apply by filling out this form.

    • gpt-4
    • gpt-4-32k

    The gpt-4 supports 8192 max input tokens and the gpt-4-32k supports up to 32,768 tokens.

    GPT-3 models

    The GPT-3 models can understand and generate natural language. The service offers four model capabilities, each with different levels of power and speed suitable for different tasks. Davinci is the most capable model, while Ada is the fastest. In the order of greater to lesser capability, the models are:

    • text-davinci-003
    • text-curie-001
    • text-babbage-001
    • text-ada-001

    While Davinci is the most capable, the other models provide significant speed advantages. Our recommendation is for users to start with Davinci while experimenting, because it produces the best results and validate the value that Azure OpenAI can provide. Once you have a prototype working, you can then optimize your model choice with the best latency/performance balance for your application.

    So Davinci is the most capable model and can perform any task the other models can perform, often with less instruction. For applications requiring deep understanding of the content, like summarization for a specific audience and creative content generation, Davinci produces the best results. The increased capabilities provided by Davinci require more compute resources, so Davinci costs more and isn't as fast as other models.

    Another area where Davinci excels is in understanding the intent of text. Davinci is excellent at solving many kinds of logic problems and explaining the motives of characters. Davinci has been able to solve some of the most challenging AI problems involving cause and effect.

    Use for: Complex intent, cause and effect, summarization for audience


Expand
titleComparative Table

Image Added

Expand
titlePricing comparison

Image Added


Expand
titleTo use GPT API in our app, how to know how much do we need tokens

The number of API tokens you will need to use the GPT-3 API in your app will depend on how frequently you plan to make API requests and how large those requests are.

OpenAI currently offers several different pricing tiers for API access, which are based on the number of tokens you purchase. The pricing tiers range from 400,000 tokens per month to 3 billion tokens per month, with the cost per token decreasing as you purchase larger quantities.

To estimate how many tokens you will need, you can start by calculating the average number of API requests your app will make per day, and the average size of those requests in terms of the number of tokens consumed per request. You can then use this information to determine how many tokens you will need on a monthly basis.

It's important to note that OpenAI has strict usage limits and guidelines for the GPT-3 API, and they reserve the right to suspend or terminate API access for users who violate these guidelines or exceed their usage limits. You should review the OpenAI API documentation carefully and ensure that your app complies with all usage guidelines and policies.

Expand
titleHow much do we need to pay per month?

OpenAI offers a few different pricing plans for their API, and the cost per month will depend on the plan you choose and the number of tokens you purchase.

  • The current pricing plans are as follows:
    • Developer plan: $60/month for 400,000 tokens
    • Team plan: $300/month for 3,000,000 tokens
    • Business plan: custom pricing for larger token amounts
  • The cost per token decreases as you purchase larger quantities, and there are additional discounts available for annual commitments.
  • You can purchase additional tokens through the OpenAI dashboard using a credit card or bank transfer.
  • The exact payment methods available may vary depending on your location and the size of your purchase.
  • It's important to note that these prices are subject to change, and you should consult the OpenAI website or contact their sales team for the most up-to-date pricing information.


  • The pricing for the OpenAI API also depends on the model you use and the number of API requests you make.

  • Each API request consumes a certain number of tokens, which are deducted from your account balance.

    The GPT-3 model is one of the most expensive models offered by OpenAI, with each API request consuming a minimum of 1 token per character generated. The exact number of tokens consumed per request will depend on the length and complexity of the generated text.

    The pricing plans for the OpenAI API are based on the number of tokens you purchase per month, and the cost per token decreases as you purchase larger quantities. The pricing plans also include a limit on the number of API requests you can make per month, which varies depending on the plan you choose.

    It's important to carefully consider your usage needs and choose a plan that provides enough tokens for your expected usage, as well as to monitor your usage to ensure you do not exceed your plan limits or usage guidelines.

Expand
titleHow will I know how many tokens I’ve used each month?

Log in to your account to view your usage tracking dashboard. This page will show you how many tokens you’ve used during the current and past billing cycles.

Expand
titleHow can I manage my spending?

You can configure a usage hard limit in your billing settings, after which we’ll stop serving your requests. You may also configure a soft limit to receive an email alert once you pass a certain usage threshold. There may be a delay in enforcing the limit, and you are responsible for any overage incurred. We recommend checking your usage tracking dashboard regularly to monitor your spend.

Expand
titleHow is pricing calculated for Completions?
  • Completions requests are billed based on the number of tokens sent in your prompt plus the number of tokens in the completion(s) returned by the API.
  • The best_of and n parameters may also impact costs. Because these parameters generate multiple completions per prompt, they act as multipliers on the number of tokens returned.
  • Your request may use up to num_tokens(prompt) + max_tokens * max(n, best_of) tokens, which will be billed at the per-engine rates outlined at the top of this page.
  • In the simplest case, if your prompt contains 10 tokens and you request a single 90 token completion from the davinci engine, your request will use 100 tokens and will cost $0.002.
  • You can limit costs by reducing prompt length or maximum response length, limiting usage of best_of/n, adding appropriate stop sequences, or using engines with lower per-token costs.
Expand
titleAPI Limitation

As a language model based on the GPT-3 architecture, the GPT-3 API has some limitations, including:

  • Rate Limits check this link
  • Limited control over outputs: While the GPT-3 API can generate high-quality text, it may not always produce the output you want. It can be difficult to control the direction of the text or ensure that it stays on topic.
  • Expensive pricing: The GPT-3 API can be quite expensive to use, especially for large-scale projects. This can be a limiting factor for individuals or small businesses who want to use the API but don't have the resources to do so.
  • Limited access: Currently, the GPT-3 API is only available to selected partners and developers. This means that not everyone has access to the API, which can limit its usefulness in certain contexts.
  • Bias and fairness issues: As with any AI system, the GPT-3 API is not immune to bias and fairness issues. These issues can affect the accuracy and usefulness of the model, particularly in sensitive areas such as healthcare or criminal justice.
  • Lack of transparency: The GPT-3 API is a proprietary system, and its inner workings are not transparent to the public. This can make it difficult to assess the model's accuracy and potential biases.
Expand
titleWhat would be the best Model to use
  • We can use the GPT comparison tool that lets us run different models side-by-side to compare outputs, settings, and response times and then download the data into an Excel spreadsheet.
  • Under the examples section, we can benefit from examples to choose what we want
  • For example we can use text-davinci-003 for SQL Translation

          Image Added

          Image Added

  • Other example we can benefit from, to reduce the email content, before sending it in the prompt:  using text-davinci-003

          For sure we need to test how limited the # of tokens in this example prompt itself

         Image Added                                                   or                    Image Added

         Image Added                                                Image Added

  • For retrieving data from the email we can try one of these examples: using text-davinci-003

         Image Added                            or                      Image Added

         Image Added                                                Image Added

Expand
titleUse Cases
  • Classification
  • Translation
  • Summarization
  • Copywriting
  • Parsing unstructured text
Expand
titleHow to test this API & get an API key

In order to test the API we need to get an API Key:

  • OpenAI provides a free tier for the GPT-3 API that allows developers to experiment with the API and build small-scale applications without incurring any costs.

  • The free tier provides access to a limited number of API requests per month, after which you will need to upgrade to a paid plan to continue using the API.
  • It's important to note that the availability and terms of these resources may change over time, so it's best to check with OpenAI directly for the most up-to-date information on their programs and offerings.
  • Supported languages: it provides several SDKs and libraries to use the API in different programming languages, including Python, Node.js, Java, Ruby, C#
  • The OpenAI API uses API keys for authentication. Visit your API keys page to retrieve the API key you'll use in your requests.

  • Avoid exposing the API keys in your code or in public repositories; instead, store them in a secure location. You should expose your keys to your application using environment variables or secret management service, so that you don't need to hard-code them in your codebase. Read more in our Best practices for API key safety.

  • I've found 2 ways to get an API Key:
    • Expand
      titleApply for access _ GPT-4

      Steps: 

      Note that in the new documentation under the Products section we can't find GPT-3 we find GPT-4, so the below section refer to GPT-4 instead of GPT-3

      • Go to the OpenAI website: Visit the OpenAI website at https://openai.com/.
      • Click on "Products": From the OpenAI homepage, click on the "Products" tab located in the top navigation menu.
      • Click on "GPT-3": From the Products page, click on the "GPT-3" option to learn more about the API.
      • Click on "Apply for Access": Once you have reviewed the information about the GPT-3 API, click on the Join API waitlist button located on the GPT-3 page.
      • Fill out the application form: Fill out the application form with your personal and project information. You will need to provide information about your intended use of the API, as well as your technical expertise and experience.
      • Agree to the terms: Read and agree to the terms of the GPT-3 API access agreement.
      • Submit your application: Once you have completed the application form and agreed to the terms, submit your application for review.
      • Wait for approval: The review process can take several weeks, and not all applications are approved. If your application is approved, you will receive an email with instructions on how to set up your account and obtain an API key.
      • Set up your account: Follow the instructions in the email to set up your OpenAI account. You will need to create a password and verify your email address.
      • Obtain your API key: Once your account is set up, log in to the OpenAI developer dashboard (https://beta.openai.com/login/) and navigate to the API keys section. Here you will find your API key, which you can copy and use in your application.
    • Expand
      titleGenerate an API Key
      1. Go to the OpenAI website at https://openai.com/
      2. Log into your OpenAI dashboard
      3. Click your profile icon at the top right
      4. Go to View API Keys and click Create new secret key to generate your API secret key.

      Below you can find a way suggested by chatGPT to generate an API Key for specific model for ex. for text-davinci-003;  but couldn't find it:

      1. Go to the OpenAI website at https://openai.com/
      2. Click on the "Get Started for Free" button in the top right corner of the page.
      3. Sign up for an OpenAI account by providing your email address and a password.
      4. Once you've signed up, log in to your OpenAI account.
      5. Navigate to the API Keys section of your account dashboard.
      6. Create a new API key by clicking the "New API Key" button.
      7. Select the text-davinci-003 model from the dropdown menu of available models.
      8. Give your API key a name and description, if desired.
      9. Click the "Create API Key" button to generate your new API key.
  • Create Request body
  • Expand
    titleHow to Use the OpenAI API

    The OpenAI API usage is simple and follows the conventional API consumption pattern.

    1. Install the openai package using pip: pip install openai. If using Node instead, you can do so using npm: npm install openai.
    2. Grab your API keys: Log into your OpenAI dashboard and click your profile icon at the top right. Go to View API Keys and click Create new secret key to generate your API secret key.
    3. Make API calls to your chosen model endpoints via a server-side language like Python or JavaScript (Node). Feed these to your custom APIs and test your endpoints.
    4. Then fetch custom APIs via JavaScript frameworks like React, Vue, or Angular.
    5. Present data (user requests and model responses) in a visually appealing UI, and your app is ready for real-world use.
Expand
titleTokens number limitation
  • What are tokens and how to count them?
  • You can think of tokens as pieces of words, where 1,000 tokens is about 750 words. 
  • It's used for natural language processing. For English text, 1 token is approximately 4 characters or 0.75 words. As a point of reference, the collected works of Shakespeare are about 900,000 words or 1.2M tokens.

    To learn more about how tokens work and estimate your usage…

    • Experiment with our interactive Tokenizer tool.
    • Log in to your account and enter text into the Playground. The counter in the footer will display how many tokens are in your text.


  • The allowed number of tokens to use depends on the model used, for example for text-davinci-003 requests can use up to 4097 tokens shared between prompt and completion. If your prompt is 4000 tokens, your completion can be 97 tokens at most.
  • The limit is currently a technical limitation
  • Solution: there are often creative ways to solve problems within the limit, e.g. condensing the prompt, breaking the text into smaller pieces, etc.
  • Techniques for improving reliability around prompts

Even with careful planning, it's important to be prepared for unexpected issues when using GPT-3 in your application. In some cases, the model may fail on a task, so it's helpful to consider what you can do to improve the reliability of your application.

If your task involves logical reasoning or complexity, you may need to take additional steps to build more reliable prompts. For some helpful suggestions, consult our Techniques to improve reliability guide. Overall the recommendations revolve around:

    • Decomposing unreliable operations into smaller, more reliable operations (e.g., selection-inference prompting)
    • Using multiple steps or multiple relationships to make the system's reliability greater than any individual component (e.g., maieutic prompting)
Expand
titleAPI Data Usage Policies
  • Data usage policies can be found  here 
  • API usage policies can be found  here
Expand
titleProduction best practices

Follow this link to get more info

Expand
titleBest practices for prompt engineering with OpenAI API

How prompt engineering works

Due to the way the instruction-following models are trained or the data they are trained on, there are specific prompt formats that work particularly well and align better with the tasks at hand. Below we present a number of prompt formats we find work reliably well, but feel free to explore different formats, which may fit your task best.

Rules of Thumb and Examples :

Note: the "{text input here}" is a placeholder for actual text/context

1. Use the latest model

For best results, we generally recommend using the latest, most capable models. As of November 2022, the best options are the “text-davinci-003” model for text generation, and the “code-davinci-002” model for code generation.

2. Put instructions at the beginning of the prompt and use ### or """ to separate the instruction and context

Less effective ❌:

Summarize the text below as a bullet point list of the most important points.
{text input here}

Better ✅:

Summarize the text below as a bullet point list of the most important points.
Text: """
{text input here}
"""

3. Be specific, descriptive and as detailed as possible about the desired context, outcome, length, format, style, etc

Be specific about the context, outcome, length, format, style, etc

Less effective ❌:

Write a poem about OpenAI.

Better ✅:

Write a short inspiring poem about OpenAI, focusing on the recent DALL-E product launch (DALL-E is a text to image ML model) in the style of a {famous poet}

4. Articulate the desired output format through examples (example 1, example 2).

Less effective ❌:

Extract the entities mentioned in the text below. Extract the following 4 entity types: company names, people names, specific topics and themes.
Text: {text}

Show, and tell - the models respond better when shown specific format requirements. This also makes it easier to programmatically parse out multiple outputs reliably.

Better ✅:

Extract the important entities mentioned in the text below. First extract all company names, then extract all people names, then extract specific topics which fit the content and finally extract general overarching themes
Desired format:
Company names: <comma_separated_list_of_company_names>
People names: -||-
Specific topics: -||-
General themes: -||-

Text: {text}

5. Start with zero-shot, then few-shot (example), neither of them worked, then fine-tune

✅ Zero-shot

Extract keywords from the below text.
Text: {text}

Keywords:

✅ Few-shot - provide a couple of examples

Extract keywords from the corresponding texts below.
Text 1: Stripe provides APIs that web developers can use to integrate payment processing into their websites and mobile applications.
Keywords 1: Stripe, payment processing, APIs, web developers, websites, mobile applications
##
Text 2: OpenAI has trained cutting-edge language models that are very good at understanding and generating text. Our API provides access to these models and can be used to solve virtually any task that involves processing language.
Keywords 2: OpenAI, language models, text processing, API.
##
Text 3: {text}
Keywords 3:

✅Fine-tune: see fine-tune best practices here.

6. Reduce “fluffy” and imprecise descriptions

Less effective ❌:

The description for this product should be fairly short, a few sentences only, and not too much more.

Better ✅:

Use a 3 to 5 sentence paragraph to describe this product.

7. Instead of just saying what not to do, say what to do instead

Less effective ❌:

The following is a conversation between an Agent and a Customer. DO NOT ASK USERNAME OR PASSWORD. DO NOT REPEAT.
Customer: I can’t log in to my account.
Agent:

Better ✅:

The following is a conversation between an Agent and a Customer. The agent will attempt to diagnose the problem and suggest a solution, whilst refraining from asking any questions related to PII. Instead of asking for PII, such as username or password, refer the user to the help article 
Customer: I can’t log in to my account.
Agent:

8. Code Generation Specific - Use “leading words” to nudge the model toward a particular pattern

Less effective ❌:

# Write a simple python function that

# 1. Ask me for a number in mile
# 2. It converts miles to kilometers

In this code example below, adding “import” hints to the model that it should start writing in Python. (Similarly “SELECT” is a good hint for the start of a SQL statement.)

Better ✅:

# Write a simple python function that

# 1. Ask me for a number in mile
# 2. It converts miles to kilometers
 
import

Parameters

Generally, we find that modelandtemperature are the most commonly used parameters to alter the model output.

    • model: Higher performance models are more expensive and have higher latency.
    • temperatureA measure of how often the model outputs a less likely token. The higher the temperature, the more random (and usually creative) the output. This, however, is not the same as “truthfulness”. For most factual use cases such as data extraction, and truthful Q&A, the temperature of 0 is best.
    • max_tokens (maximum length):  Does not control the length of the output, but a hard cutoff limit for token generation. Ideally you won’t hit this limit often, as your model will stop either when it thinks it’s finished, or when it hits a stop sequence you defined.
    • stop (stop sequences):  A set of characters (tokens) that, when generated, will cause the text generation to stop.

For other parameter descriptions see the API reference.


  • Go to the OpenAI website at https://openai.com/.
  • Click on the "Get Started for Free" button in the top right corner of the page.
  • Sign up for an OpenAI account by providing your email address and a password.
  • Once you've signed up, log in to your OpenAI account.
  • Navigate to the API Keys section of your account dashboard.
  • Create a new API key by clicking the "New API Key" button.
  • Select the text-davinci-003 model from the dropdown menu of available models.
  • Give your API key a name and description, if desired.
  • Click the "Create API Key" button to generate your new API key.
    Expand
    titleDemo project results

    GPT-3.5-turbo vs. text-davinci-003 vs. text-davinci-002:

    Expand
    titleCreate Completion

    for the following prompt: (same parameters are used for text-davinci- 003 & 002)

    `As a Jira User create a Jira ticket filling (summary, priority, assignee, dueDate, issueType, project) from this content "Hi Jessica Please prepare a report of the marketing activities for february 2023 please i need it as soon as possible"`

    Results: with a comparison of the total number of tokens used per request

    Using  gpt-3.5-turbo - createChatCompletion

    Image Added


    Using  text-davinci-003 - createCompletion

    Image Added


    Using  text-davinci-002 - createCompletion

    Image Added

    Expand
    titleTranslation prompt testing:

    Translation prompt testing:

    "Translate this natural language into JQL Query by following this JSON format {project , issueType}: show issues related to analytics project";

    Results: with a comparison of the total number of tokens used per request

    Using gpt-3.5-turbo model - createChatCompletion

    Image Added


    Using text-davinci-003 model - createCompletion

    Image Added


    Using text-davinci-002 model - createCompletion

    Image Added

    Expand
    titleHow to test this API & get an API key

    In order to test the API we need to get an API Key:

  • OpenAI provides a free tier for the GPT-3 API that allows developers to experiment with the API and build small-scale applications without incurring any costs.

  • The free tier provides access to a limited number of API requests per month, after which you will need to upgrade to a paid plan to continue using the API.
  • It's important to note that the availability and terms of these resources may change over time, so it's best to check with OpenAI directly for the most up-to-date information on their programs and offerings.
  • Supported languages: it provides several SDKs and libraries to use the API in different programming languages, including Python, Node.js, Java, Ruby, C#
  • I've found 2 ways to get an API Key:
  • Expand
    titleApply for access

    Steps: 

    Note that in the new documentation we can't find GPT-3 we find GPT-4

    • Go to the OpenAI website: Visit the OpenAI website at https://openai.com/.
    • Click on "Products": From the OpenAI homepage, click on the "Products" tab located in the top navigation menu.
    • Click on "GPT-3": From the Products page, click on the "GPT-3" option to learn more about the API.
    • Click on "Apply for Access": Once you have reviewed the information about the GPT-3 API, click on the "Apply for Access" button located on the GPT-3 page.
    • Fill out the application form: Fill out the application form with your personal and project information. You will need to provide information about your intended use of the API, as well as your technical expertise and experience.
    • Agree to the terms: Read and agree to the terms of the GPT-3 API access agreement.
    • Submit your application: Once you have completed the application form and agreed to the terms, submit your application for review.
    • Wait for approval: The review process can take several weeks, and not all applications are approved. If your application is approved, you will receive an email with instructions on how to set up your account and obtain an API key.
    • Set up your account: Follow the instructions in the email to set up your OpenAI account. You will need to create a password and verify your email address.
    • Obtain your API key: Once your account is set up, log in to the OpenAI developer dashboard (https://beta.openai.com/login/) and navigate to the API keys section. Here you will find your API key, which you can copy and use in your application.
  • Expand
    titleGenerate an API Key for specific model for ex. for text-davinci-003